Node: EADDRINUSE: address already in use; Solved

blog image

Got this error anytime? Well, this is the most common error we get while starting a node server or running a node application.

But do you know what does this error mean?

EADDRINUSE (address already in use) error occurs when the port number where you want to start your server is already in use by other server.

For example: if you are running a node application on port number 3000. And if you try to start another server on the same port number, you will get the error.

Another instance, where you have already started the node server for your application and try to run the same application without stopping the previous instance, you will receive EADDRINUSE error.

Now, coming back to the Solution to the error:

  1. Identify the process running on the same port number and stop it. Then, run your application
  2. Change the port number in application and try running it. (if any important process is running on the port number and you don’t want to stop it, you can simply change the port number in your application and run the program)
ps aux | grep node

use this command to identify the processes running with their process ids.

Once, you identify the process id, execute below command. In above output, 535650 is the process id where node is running.

kill -9 PID

where PID should be replaced with process id. So, kill -9 535650 will kill the node process and the port will be available to reuse.

Happy Coding!

×
×

Ready to scale up your business?

Follow Us