2

I have simple server written in Express. But when I use my server and close project, after reopening project I always get

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

Error: listen EADDRINUSE :::8005
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server._listen2 (net.js:1257:14)
    at listen (net.js:1293:10)
    at Server.listen (net.js:1389:5)
    at EventEmitter.listen (/Users/macbookair/Documents/Computer Science/Software Development/JS/Node/nodecrudserver/node_modules/express/lib/application.js:617:24)
    at Object.<anonymous> (/Users/macbookair/Documents/Computer Science/Software Development/JS/Node/nodecrudserver/index.js:198:5)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

Process finished with exit code 1

if I change port number then all is OK but why do I get above exception and how to avoid it?

  • 1
    *"why do I get above exception"* Because another process already listens to that port. There can only be one process listening to a port. – Felix Kling Feb 12 '17 at 17:33
  • 1
    EADDRINUSE error will come when you are attempting to bind a server to local address failed. It will fail when port is listening to some other. In your case, you may be binding the server to the local address and you may not be closing it. As a result, internally, the port is listening but you are terminating the project. So when you reopening the project and running , you are getting this error. – sreepurna Feb 22 '17 at 05:10

0 Answers0