How to kill a node process in Mac and Windows

I was recently setting up a react project and was getting error saying port in use. And unlike in mac , needed few more commands to make it work in windows.

So when you want to kill a port, first it helps to find out which app is using it. Find the PID number and then use that to kill the process

netstat -ano | find "LISTENING" | find "3001"

taskkill /pid <pid number from above> -f

If you want to kill all processes, you can use this command

taskkill /im node.exe

Remember you might have to use -f to force it. Also make sure to run the terminal with admin privileges

In mac, you can use killall

killall node

To kill specific port number in use in mac, use the lsof command

lsof -i:3001

Note down the PID number just like in windows. And then use the kill command like below

kill -9 <pid number from above>

Leave a comment

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