April 18, 2019
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.
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.1
-i flag allows for inclusion of specific ports.
In my case, I was interested in port
5001, so the command was
lsof -i :5001.
Update: It’s possible to kill the process directly from the shell using the
kill command, e.g.,
Now when I restarted the server it worked like a charm.
Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!