简体   繁体   中英

nodemon giving this error code: 'EADDRINUSE', errno: -4091, syscall: 'listen', address: '::', port: 5000

Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1347:8)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '::',
  port: 5000
}
[nodemon] app crashed - waiting for file changes before starting...

Having the same problem but I have 3 fixes for this you can use any

  • 1. a permanent and long way:

    • i. Install the kill-port node package as a dev dependency:

       npm install kill-port --save-dev
    • ii. Create a nodemon.json file in the root of your project containing:

       { "events": { "restart": "kill-port 5000", "crash": "kill-port 5000" }, "delay": "1500" }
    • iii. Then, in your package.json file, have something like this:

       "scripts": { "start-dev": "nodemon app.js", }
    • iv. Then start your app in dev mode with:

       npm run start-dev
  • 2. Manually kill from the system(easy fix):

    directly kill the port with the following command.

     fuser -n tcp -k 5000
  • 3. Restarting the system:

    • restarting the project
    • restarting the computer
for windows

netstat -ano | findstr : 5000
(output : TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 18264)
taskkill /PID 18264 /f


Mainly this error comes when we run our code on same port or port already busy, so we have to kill the process

for ubuntu

fuser -k 5000/tcp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM