How to stop all instances of a node.js server

Sometimes when you’re developing, the node.js process will keep running even though it has been stopped in the terminal. This calls for some drastic measures to kill the node processes.

This process is slightly different on Windows vs Linux machines.

How to kill all node.js processes on Windows

taskkill /im node.exe

If the issue is not resolved, try the following command with the “force” flag

taskkill /f /im node.exe

How to kill all node.js processes on Linux

Similar to Windows, you can use the following command to kill all node.js processes.

killall node 

If this does not resolve the issue, you should follow the following process. Use this command to determine the process ID of a particular process.

$ netstat -nlp | grep :8080 tcp        0      0*                   LISTEN      1073/node  

Get the process ID from the last column and target the process like this:

$ kill 1073

If the process doesn’t not want to exit, use the “force” flag of 9

$ kill -9 1073