stop all instances of node.js server

前端 未结 16 1678
我在风中等你
我在风中等你 2020-11-28 17:23

This is my first time working with Node.js and I ran into this problem:

I have started a Node server through the plugin of an IDE. Unfortunately, I cannot use the ID

相关标签:
16条回答
  • 2020-11-28 17:52

    Am Using windows Operating system.

    I killed all the node process and restarted the app it worked.

    try

    taskkill /im node.exe
    
    0 讨论(0)
  • 2020-11-28 17:53

    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.

    0 讨论(0)
  • 2020-11-28 17:53

    in windows command Type command blow:

    taskkill /f /im node.exe

    0 讨论(0)
  • 2020-11-28 17:55

    Windows Machine:

    Need to kill a Node.js server, and you don't have any other Node processes running, you can tell your machine to kill all processes named node.exe. That would look like this:

    taskkill /im node.exe
    

    And if the processes still persist, you can force the processes to terminate by adding the /f flag:

    taskkill /f /im node.exe
    

    If you need more fine-grained control and need to only kill a server that is running on a specific port, you can use netstat to find the process ID, then send a kill signal to it. So in your case, where the port is 8080, you could run the following:

    C:\>netstat -ano | find "LISTENING" | find "8080"
    

    The fifth column of the output is the process ID:

      TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       14828
      TCP    [::]:8080              [::]:0                 LISTENING       14828
    

    You could then kill the process with taskkill /pid 14828. If the process refuses to exit, then just add the /f (force) parameter to the command.


    Linux machine:

    The process is almost identical. You could either kill all Node processes running on the machine (use -$SIGNAL if SIGKILL is insufficient):

    killall node
    

    Or also using netstat, you can find the PID of a process listening on a port:

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

    The process ID in this case is the number before the process name in the sixth column, which you could then pass to the kill command:

    $ kill 1073
    

    If the process refuses to exit, then just use the -9 flag, which is a SIGTERM and cannot be ignored:

    $ kill -9 1073
    
    0 讨论(0)
  • 2020-11-28 17:57

    Windows & GitBash Terminal I needed to use this command inside Windows / Webstorm / GitBash terminal

    cmd "/C TASKKILL /IM node.exe /F"
    
    0 讨论(0)
  • 2020-11-28 18:00

    it works fine in windows 10

    taskkill /f /im node.exe
    
    0 讨论(0)
提交回复
热议问题