How to kill a process running on a port

August 30, 2020

To find the process id (on port 5000):

lsof -i:5000

Output:

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    66070 apollo   19u  IPv6 569875      0t0  TCP *:5000 (LISTEN)

Here you can see the process id. You'll need this id to kill the process.

To kill the process:

kill 66070

That's it.

If this does not work, try:

kill -9 66070

This will send the SIGKILL signal wich will immediately kill the process.