0

I am using the command nodemon, and the first time I do so, localhost serves all the files correctly. However, when I make any changes, or when I quit out of nodemon(ctrl + c) and run nodemon again, I get this error:

events.js:182
  throw er; // Unhandled 'error' event
  ^

Error: listen EADDRINUSE :::3000
    at Object._errnoException (util.js:1019:11)
    at _exceptionWithHostPort (util.js:1041:20)
    at Server.setupListenHandle [as _listen2] (net.js:1344:14)
    at listenInCluster (net.js:1385:12)
    at Server.listen (net.js:1469:7)
    at Function.listen 

  (D:\Apps\NodeJs\Test\node_modules\express\
    lib\application.js:
    618:24)
    at Object.<anonymous> 
  (D:\Apps\NodeJs\Test\app.js:95:5)
  at Module._compile (module.js:624:30)
  at Object.Module._extensions..js (module.js:635:10)
  at Module.load (module.js:545:32)
  [nodemon] app crashed - waiting for file changes before starting...

I noticed in my processes, that Node.js:Server-side Javascript is running, even though I have killed my nodemon process. When I simply run node app.js, I don't have an issue. I understand that the port is already being used to serve my files, hence this error, but I'm not sure why escaping out of nodemon doesn't kill the process and free up the port again?

simmonson
  • 137
  • 1
  • 9
  • Are you running nodemon in verbose mode? Is it a global installation or local installation? Please include the full command. – cinnaroll45 Oct 10 '17 at 20:30

1 Answers1

0

Nodemon executes your program in another process, so when you call it you'll have a nodemon and you app running in different processes. My recommendation is to add an exit handler for your program to close the port, you can see how to do that in this question

Sacha
  • 245
  • 2
  • 10