stop all instances of node.js server

前端 未结 16 1676
我在风中等你
我在风中等你 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:39

    Press in cmd or bash : Ctrl + C

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

    Multiplatform, stable, best solution:

    use fkill to kill process which is taking your port:

    fkill -f :8080
    

    To install fkill use command: npm i -g fkill

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

    The fastest way is

    killall node
    

    Works with Linux, OS X

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

    If you are using Windows, follow this:

    1. Open task manager, look for this process:

    2. Then just right click and "End task" it.

    3. That's it, now all the npm commands run form the start.

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

    You can use lsof get the process that has bound to the required port.

    Unfortunately the flags seem to be different depending on system, but on Mac OS X you can run

    lsof -Pi | grep LISTEN
    

    For example, on my machine I get something like:

    mongod     8662 jacob    6u  IPv4 0x17ceae4e0970fbe9      0t0  TCP localhost:27017 (LISTEN)
    mongod     8662 jacob    7u  IPv4 0x17ceae4e0f9c24b1      0t0  TCP localhost:28017 (LISTEN)
    memcached  8680 jacob   17u  IPv4 0x17ceae4e0971f7d1      0t0  TCP *:11211 (LISTEN)
    memcached  8680 jacob   18u  IPv6 0x17ceae4e0bdf6479      0t0  TCP *:11211 (LISTEN)
    mysqld     9394 jacob   10u  IPv4 0x17ceae4e080c4001      0t0  TCP *:3306 (LISTEN)
    redis-ser 75429 jacob    4u  IPv4 0x17ceae4e1ba8ea59      0t0  TCP localhost:6379 (LISTEN)
    

    The second number is the PID and the port they're listening to is on the right before "(LISTEN)". Find the rogue PID and kill -9 $PID to terminate with extreme prejudice.

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

    you can try

    killall node
    

    you can also try

    killall nodejs
    
    0 讨论(0)
提交回复
热议问题