Stop node.js program from command line

后端 未结 19 2205
无人及你
无人及你 2020-11-29 14:51

I have a simple TCP server that listens on a port.

var net = require(\"net\");

var server = net.createServer(function(socket) {
    socket.end(\"Hello!\\n\"         


        
相关标签:
19条回答
  • 2020-11-29 14:52

    Ctrl+Z suspends it, which means it can still be running.

    Ctrl+C will actually kill it.

    you can also kill it manually like this:

    ps aux | grep node
    

    Find the process ID (second from the left):

    kill -9 PROCESS_ID
    

    This may also work

    killall node
    
    0 讨论(0)
  • 2020-11-29 14:53

    Late answer but on windows, opening up the task manager with CTRL+ALT+DEL then killing Node.js processes will solve this error.

    0 讨论(0)
  • 2020-11-29 14:54

    For MacOS

    1. Open terminal
    2. Run the below code and hit enter

       sudo kill $(sudo lsof -t -i:4200)
      
    0 讨论(0)
  • 2020-11-29 14:54

    For windows first search the PID with your port number

    netstat -ano | findStr "portNumber"
    

    After that, kill the task, make sure you are in root of your "c" drive And the command will be taskkill /F /PID your pid

    0 讨论(0)
  • 2020-11-29 14:55

    $ sudo killall node in another terminal works on mac, while killall node not working:

    $ killall node
    No matching processes belonging to you were found
    
    0 讨论(0)
  • 2020-11-29 14:55

    on linux try: pkill node

    on windows:

    Taskkill /IM node.exe /F
    

    or

    from subprocess import call
    
    call(['taskkill', '/IM', 'node.exe', '/F'])
    
    0 讨论(0)
提交回复
热议问题