warn – error raised: Error: listen EADDRINUSE

Seeing this error “warn – error raised: Error: listen EADDRINUSE”? Well let’s see how we can solve it.

Image

About the error

This error is caused by the port number already being used by another process. So we need to find that process and kill it.

The Best Solution

linux find all active processes

netstat -tulpn

Image

OR linux find process by specific port

netstat -tulpn | grep :8080

Image

To kill the process by id.

kill -9 <processid>

So for our found process it’s 29845.

kill -9 29845

Note: The -9 bit is required to ensure the process is effectively killed even if it is unresponsive (we’re telling the OS to kill the program directly and the application knows nothing about it and thus cannot be ignored).

Image

The process has now been killed and our node server should start normally on that port we specified.