When I update the project Files I get this issue given Below:
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::4000
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Function.listen (E:\nodejs-mysql-authentication- master\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (E:\nodejs-mysql-authentication-master\server.js:26:5)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
[nodemon] app crashed - waiting for file changes before starting...
I already try all this point to short out this issue given below
1.I manually stops the all node services than again I try npm start It's not worked if i change port 4001 it's work after, some time again same issue port 4001.
2.I Increase the nodemon file watcher size but still this issue not get solved.
But When I restart My PC again then nodemon is working on same port. So How I can solve this issue, If I don't want to change my port and can't restart my PC.
Adding --signal SIGTERM
to nodemon command line fixed for me. You can have more details at nodemon project @ github.com
The issue occurs due to a thread still running when nodemon restarts the app, and this thread is already using the port you want to use. You can confirm this with these steps:
CTRL+c
when it happens to stop nodemonnetstat -napt | grep [YOUR_PORT]
, replace [YOUR_PORT] with the port number you are using. In the OP's case it's 4000you should get the process listening on that port. The command will return something like this:
ff@darkpc:~/dev/dp/graphql/teste1> netstat -napt | grep 4000
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::4000 :::* LISTEN 31837/node8
if you try to run nodemon again it will crash!
kill 31837
in this case 31387
is the PID of node8 as you can see aboveAdding the --signal SIGTERM
to nodemon command line will kill the main process and all it's threads and should fix the problem.