Kill any running port linux and mac

First of all, we need to find out the process id also known as PID of the running process on a specific port. For example, a process is running on port 3000. To find its process id, execute:

lsof -t -i:4200
63562

Now you have the PID ‘63562’ of the process running on a port. Use the kill command to terminate that process by its PID.

sudo kill -9 63562 

There is also a short version of killing the port.

sudo kill -9 $(sudo lsof -t -i:4200)

Hope it helps.

Leave a Reply

Your email address will not be published. Required fields are marked *