Last Updated: February 25, 2016
·
1.854K
· maxcnunes

Error: listen EADDRINUSE

This is a common error raised by express notifying that the port listened by your app has already been used.

So, to solve this we have 2 options:

  1. Choose another port for your app (the easiest way).
  2. Kill any process that is using that port.

If you are working only with node, probably the process that is using that port is another node app. So to discover the process id, just search by any node process.

ps aux | grep node

Then to kill that process by its id:

kill PROCESS_ID_HERE

But, if that not solve your problem or you want to get more information about the process that is blocking your chosen port, you can follow these other steps:

To ensure there is a process running in that port, execute this command (e.g. port 8000):

netstat -anp tcp | grep 8000

Then you can discover the process id, just search by the port number.

lsof -i tcp:8000

And kill the process as I said previously.