How to solve nodejs Error: listen EADDRINUSE?

In this post we are going to discuss about how to solve Node.js error: listen EADDRINUSE. EADDRINUSE actually means that the port number which you are binding to the server using listen() is already in use.

Error: listen EADDRINUSE means the port which you want to assign/bind to your application server is already in use. You can either assign another port to your application.

Or if you want to assign the same port to the app. Then kill the application that is running at your desired port.

If any application is already running on 3000 then you will get the below error (Error: listen EADDRINUSE). Here is the screenshot of error:

To solve this error either you start your node server on another port or close the program using that port. If you use lsof, you can see what process is bound to the port with lsof -i:3000, and then force kill it by grabbing the process id (aka pid) and kill it with a kill -9 $pid.

You'll only see it if you have permissions; if you're running lsof as a different user than the app, try prefixing lsof -i:$port with sudo to make sure you have adequate permissions.

What really helped for me was:
killall -9 node
But this will kill a system process.

Ref: https://teamtreehouse.com/community/hi-its-throwing-an-error-listen-eaddrinuse-3000-unhandled-error-event

Comments

Popular Posts