DEV Community

Stephen Charles Weiss
Stephen Charles Weiss

Posted on • Originally published at on

Error Handling: Address In Use

Running my node server, I got an error indicating that my port was already in use (Error: listen EADDRINUSE :::5001).

I knew that shouldn’t have been the case because I had only one application running on that port.

error message

Still, killing the process multiple times from the console didn’t work, so I went in search of the process ID (PID) to kill it specifically.

There are multiple ways to do this, but the one that worked for me out of the box (on Mac) was lsof which is the “list open files” program.

The -i flag allows for inclusion of specific ports.

In my case, I was interested in port 5001, so the command was lsof -i :5001.

This returned exactly what I needed: lsof example

Apparently the node server hadn’t terminated and was still using the port, but now I knew the PID. This meant I could hop over to Activity Monitor, look it up and kill it. kill activity

Now when I restarted the server it worked like a charm.


Top comments (0)