Windows machines:
Need to kill a Node.js server, and you do not run any other Node process, you can tell your machine to kill all processes named node.exe
. It looks like this:
taskkill /im node.exe
If the process continues, you can add /f
flags to force process termination :
taskkill /f /im node.exe
If you need more fine-grained control and only need to kill the server running on a specific port, you can use it netstat
to find the process ID, and then send a kill signal. So, in your case, the location of the port where8080
you can run the following command:
C:\>netstat -ano | find "LISTENING" | find "8080"
The output of fifth column is the process ID:
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 14828 TCP [::]:8080 [::]:0 LISTENING 14828
Then you can use it to kill the process taskkill /pid 14828
. If the process refused to quit, then simply /f
(force) parameters added to the command.
Linux machines:
This process is almost identical. You can kill all Node processes running on the machine (-$SIGNAL
if SIGKILL
less than you use ):
killall node
Or you can use netstat
, you can find the PID listening on the port of the process:
$ netstat -nlp | grep :8080 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1073/node
In this case, the process ID is a digital process before the sixth column name, then you can pass it to the kill
command:
$ kill 1073
If the process refused to quit, then simply use the -9
logo, which is SIGTERM
and can not be ignored:
$ kill -9 1073