Home

Kill the process locking a PORT on Mac/Linux

Solution 1: Find and Kill the process using PID

Let us assume that you want to kill a process running at localhost:3000

Find the PID using command:

sudo lsof -i :3000

Kill the process using the command:

kill -9 <PID>

Use sudo if needed

Above two commands can be combined into one like the following:

kill -9 $(lsof -ti:3000)

Solution 2

Try the following (where 3000 is your current port in use)

lsof -i :3000

then check status of the reported PID and run the following commands

ps ax | grep <PID>
kill -QUIT <PID>

Misc

To kill multiple ports:

kill -9 $(lsof -ti:3000,3001)

Find and Kill the port in one command:

lsof -ti:3000 | xargs kill

Resources

Check this StackOverflow article to try other ways



Last Updated on

Next Post: Rules vs Guidelines →

Comments