How to kill a nodejs process in Linux?
sudo netstat -lpn |grep :'3000'
3000 is port i was looking for, After first command you will have Process ID for that port
kill -9 1192
in my case 1192 was process Id of process running on 3000 PORT use -9 for Force kill the process
pkill is the easiest command line utility
pkill -f node
or
pkill -f nodejs
whatever name the process runs as for your os
—- update —- It has been raised that this does not address killing a single node process and instead kills EVERY node process. If this is desired pkill is your tool, otherwise use one of the other accepted answers
if you want to kill a specific node process , you can go to command line route and type:
ps aux | grep node
to get a list of all node process ids. now you can get your process id(pid), then do:
kill -9 PID
and if you want to kill all node processes then do:
killall -9 node
-9 switch is like end task on windows. it will force the process to end. you can do:
kill -l
to see all switches of kill command and their comments.