stop all instances of node.js server












107














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 IDE's terminal. So I tried to run the script from the command line.



This is the problem - I am using the Express module and my app is listening some port (8080). When I start the app from the command line, it throws this error:



events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:770:11)
at HTTPServer.Server._listen2 (net.js:910:14)
at listen (net.js:937:10)
at HTTPServer.Server.listen (net.js:986:5)
at Object.<anonymous> (C:xampphtdocsnodechatapp.js:5:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)


Even though I am not very sure what this error could be I assumed that it's because the app is listening on a port which is already in use. So I did:



netstat -an


I can see



TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING


It's because the Node server is already started when I tried to start it from the IDE.



So I want to know, how can I stop all server instances? Also if you can tell me how to detect what's running on a port and kill it.










share|improve this question
























  • Sorry I dint mention that I am on windows environment. Please post commands that are relevant. Thanks
    – Kiran Ambati
    Feb 9 '13 at 20:08










  • and also you can find the node.js task in your windows taskmanager. find the progress which name is Node.js:Server-side...and open it's detail info,you will find the pid and detail of your nodejs progress
    – Xiuying Lan
    Dec 27 '17 at 3:09
















107














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 IDE's terminal. So I tried to run the script from the command line.



This is the problem - I am using the Express module and my app is listening some port (8080). When I start the app from the command line, it throws this error:



events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:770:11)
at HTTPServer.Server._listen2 (net.js:910:14)
at listen (net.js:937:10)
at HTTPServer.Server.listen (net.js:986:5)
at Object.<anonymous> (C:xampphtdocsnodechatapp.js:5:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)


Even though I am not very sure what this error could be I assumed that it's because the app is listening on a port which is already in use. So I did:



netstat -an


I can see



TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING


It's because the Node server is already started when I tried to start it from the IDE.



So I want to know, how can I stop all server instances? Also if you can tell me how to detect what's running on a port and kill it.










share|improve this question
























  • Sorry I dint mention that I am on windows environment. Please post commands that are relevant. Thanks
    – Kiran Ambati
    Feb 9 '13 at 20:08










  • and also you can find the node.js task in your windows taskmanager. find the progress which name is Node.js:Server-side...and open it's detail info,you will find the pid and detail of your nodejs progress
    – Xiuying Lan
    Dec 27 '17 at 3:09














107












107








107


60





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 IDE's terminal. So I tried to run the script from the command line.



This is the problem - I am using the Express module and my app is listening some port (8080). When I start the app from the command line, it throws this error:



events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:770:11)
at HTTPServer.Server._listen2 (net.js:910:14)
at listen (net.js:937:10)
at HTTPServer.Server.listen (net.js:986:5)
at Object.<anonymous> (C:xampphtdocsnodechatapp.js:5:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)


Even though I am not very sure what this error could be I assumed that it's because the app is listening on a port which is already in use. So I did:



netstat -an


I can see



TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING


It's because the Node server is already started when I tried to start it from the IDE.



So I want to know, how can I stop all server instances? Also if you can tell me how to detect what's running on a port and kill it.










share|improve this question















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 IDE's terminal. So I tried to run the script from the command line.



This is the problem - I am using the Express module and my app is listening some port (8080). When I start the app from the command line, it throws this error:



events.js:71
throw arguments[1]; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:770:11)
at HTTPServer.Server._listen2 (net.js:910:14)
at listen (net.js:937:10)
at HTTPServer.Server.listen (net.js:986:5)
at Object.<anonymous> (C:xampphtdocsnodechatapp.js:5:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)


Even though I am not very sure what this error could be I assumed that it's because the app is listening on a port which is already in use. So I did:



netstat -an


I can see



TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING


It's because the Node server is already started when I tried to start it from the IDE.



So I want to know, how can I stop all server instances? Also if you can tell me how to detect what's running on a port and kill it.







javascript windows node.js express port






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 18 '14 at 6:15









hexacyanide

53.1k21124126




53.1k21124126










asked Feb 9 '13 at 19:55









Kiran Ambati

1,59441932




1,59441932












  • Sorry I dint mention that I am on windows environment. Please post commands that are relevant. Thanks
    – Kiran Ambati
    Feb 9 '13 at 20:08










  • and also you can find the node.js task in your windows taskmanager. find the progress which name is Node.js:Server-side...and open it's detail info,you will find the pid and detail of your nodejs progress
    – Xiuying Lan
    Dec 27 '17 at 3:09


















  • Sorry I dint mention that I am on windows environment. Please post commands that are relevant. Thanks
    – Kiran Ambati
    Feb 9 '13 at 20:08










  • and also you can find the node.js task in your windows taskmanager. find the progress which name is Node.js:Server-side...and open it's detail info,you will find the pid and detail of your nodejs progress
    – Xiuying Lan
    Dec 27 '17 at 3:09
















Sorry I dint mention that I am on windows environment. Please post commands that are relevant. Thanks
– Kiran Ambati
Feb 9 '13 at 20:08




Sorry I dint mention that I am on windows environment. Please post commands that are relevant. Thanks
– Kiran Ambati
Feb 9 '13 at 20:08












and also you can find the node.js task in your windows taskmanager. find the progress which name is Node.js:Server-side...and open it's detail info,you will find the pid and detail of your nodejs progress
– Xiuying Lan
Dec 27 '17 at 3:09




and also you can find the node.js task in your windows taskmanager. find the progress which name is Node.js:Server-side...and open it's detail info,you will find the pid and detail of your nodejs progress
– Xiuying Lan
Dec 27 '17 at 3:09












11 Answers
11






active

oldest

votes


















258














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





share|improve this answer



















  • 1




    sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
    – Kiran Ambati
    Feb 9 '13 at 20:00








  • 1




    process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
    – hexacyanide
    Feb 9 '13 at 20:03












  • thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
    – Kiran Ambati
    Feb 9 '13 at 20:10






  • 2




    Try taskkill /IM node.exe. It will kill all processes named node.exe.
    – hexacyanide
    Feb 9 '13 at 20:11






  • 1




    I had to use taskkill /F /IM node.exe to make it work, thanks!
    – Luis
    Nov 20 '13 at 15:35



















56














The fastest way is



killall node


Works with Linux, OS X






share|improve this answer































    41














    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.






    share|improve this answer























    • Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
      – Kiran Ambati
      Feb 9 '13 at 20:11










    • I have no idea how to do it on Windows, sorry Kiran.
      – Jacob Groundwater
      Feb 9 '13 at 20:26










    • no probs! Issue is solved. cheers
      – Kiran Ambati
      Feb 9 '13 at 20:29










    • This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
      – modulitos
      Jun 16 '14 at 20:11



















    11














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



    cmd "/C TASKKILL /IM node.exe /F"





    share|improve this answer



















    • 1




      the one that works for me
      – Anna
      Sep 1 '18 at 7:40



















    8














    You can try this:



    taskkill /IM node.exe -F





    share|improve this answer





























      7














      if you want to kill a specific process , you can go to command line route:



      ps aux | grep node


      to get process id and then
      do:



      kill -9 PID


      and if you want to kill all processes then do:



      killall -9 node





      share|improve this answer





























        2














        You could also try:



        killall nodejs






        share|improve this answer





























          0














          Am Using windows Operating system.



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



          try



          taskkill /im node.exe





          share|improve this answer





























            0














            If you are using windows, follow this:



            1) Open task manager, look for this process: http://prntscr.com/kv3uqx



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



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



            Hope it help somebody!



            Cheers






            share|improve this answer





























              0














              Use the following command to kill and restart node server from batch file



                  @echo off
              cd "D:samProjectsNode"
              taskkill /IM node.exe -F
              start /min cmd /C "node index.js"
              goto :EOF





              share|improve this answer





























                -2














                Press in cmd or bash :
                Ctrl + C






                share|improve this answer





















                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14790910%2fstop-all-instances-of-node-js-server%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  11 Answers
                  11






                  active

                  oldest

                  votes








                  11 Answers
                  11






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  258














                  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





                  share|improve this answer



















                  • 1




                    sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
                    – Kiran Ambati
                    Feb 9 '13 at 20:00








                  • 1




                    process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
                    – hexacyanide
                    Feb 9 '13 at 20:03












                  • thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
                    – Kiran Ambati
                    Feb 9 '13 at 20:10






                  • 2




                    Try taskkill /IM node.exe. It will kill all processes named node.exe.
                    – hexacyanide
                    Feb 9 '13 at 20:11






                  • 1




                    I had to use taskkill /F /IM node.exe to make it work, thanks!
                    – Luis
                    Nov 20 '13 at 15:35
















                  258














                  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





                  share|improve this answer



















                  • 1




                    sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
                    – Kiran Ambati
                    Feb 9 '13 at 20:00








                  • 1




                    process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
                    – hexacyanide
                    Feb 9 '13 at 20:03












                  • thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
                    – Kiran Ambati
                    Feb 9 '13 at 20:10






                  • 2




                    Try taskkill /IM node.exe. It will kill all processes named node.exe.
                    – hexacyanide
                    Feb 9 '13 at 20:11






                  • 1




                    I had to use taskkill /F /IM node.exe to make it work, thanks!
                    – Luis
                    Nov 20 '13 at 15:35














                  258












                  258








                  258






                  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





                  share|improve this answer














                  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






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jul 25 '17 at 16:20









                  chris Frisina

                  11.8k1759129




                  11.8k1759129










                  answered Feb 9 '13 at 19:56









                  hexacyanide

                  53.1k21124126




                  53.1k21124126








                  • 1




                    sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
                    – Kiran Ambati
                    Feb 9 '13 at 20:00








                  • 1




                    process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
                    – hexacyanide
                    Feb 9 '13 at 20:03












                  • thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
                    – Kiran Ambati
                    Feb 9 '13 at 20:10






                  • 2




                    Try taskkill /IM node.exe. It will kill all processes named node.exe.
                    – hexacyanide
                    Feb 9 '13 at 20:11






                  • 1




                    I had to use taskkill /F /IM node.exe to make it work, thanks!
                    – Luis
                    Nov 20 '13 at 15:35














                  • 1




                    sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
                    – Kiran Ambati
                    Feb 9 '13 at 20:00








                  • 1




                    process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
                    – hexacyanide
                    Feb 9 '13 at 20:03












                  • thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
                    – Kiran Ambati
                    Feb 9 '13 at 20:10






                  • 2




                    Try taskkill /IM node.exe. It will kill all processes named node.exe.
                    – hexacyanide
                    Feb 9 '13 at 20:11






                  • 1




                    I had to use taskkill /F /IM node.exe to make it work, thanks!
                    – Luis
                    Nov 20 '13 at 15:35








                  1




                  1




                  sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
                  – Kiran Ambati
                  Feb 9 '13 at 20:00






                  sorry , How exactly I can use these commands? process.exit() might be in code? but server is already started. It is likely that it is started with command node app.js but not node-dev app.js. And "node killall" is not working. Am I doing it wrong? Thank you
                  – Kiran Ambati
                  Feb 9 '13 at 20:00






                  1




                  1




                  process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
                  – hexacyanide
                  Feb 9 '13 at 20:03






                  process.exit() in your application causes the NodeJS instance to close. killall node in bash would kill all NodeJS instances running on your machine.
                  – hexacyanide
                  Feb 9 '13 at 20:03














                  thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
                  – Kiran Ambati
                  Feb 9 '13 at 20:10




                  thanks @hexacyanide . I am developing on windows. Does that make killall node an invalid command because I cannot use it from command line.
                  – Kiran Ambati
                  Feb 9 '13 at 20:10




                  2




                  2




                  Try taskkill /IM node.exe. It will kill all processes named node.exe.
                  – hexacyanide
                  Feb 9 '13 at 20:11




                  Try taskkill /IM node.exe. It will kill all processes named node.exe.
                  – hexacyanide
                  Feb 9 '13 at 20:11




                  1




                  1




                  I had to use taskkill /F /IM node.exe to make it work, thanks!
                  – Luis
                  Nov 20 '13 at 15:35




                  I had to use taskkill /F /IM node.exe to make it work, thanks!
                  – Luis
                  Nov 20 '13 at 15:35













                  56














                  The fastest way is



                  killall node


                  Works with Linux, OS X






                  share|improve this answer




























                    56














                    The fastest way is



                    killall node


                    Works with Linux, OS X






                    share|improve this answer


























                      56












                      56








                      56






                      The fastest way is



                      killall node


                      Works with Linux, OS X






                      share|improve this answer














                      The fastest way is



                      killall node


                      Works with Linux, OS X







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Feb 6 '17 at 15:01

























                      answered Oct 1 '15 at 12:15









                      zag2art

                      2,6871830




                      2,6871830























                          41














                          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.






                          share|improve this answer























                          • Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
                            – Kiran Ambati
                            Feb 9 '13 at 20:11










                          • I have no idea how to do it on Windows, sorry Kiran.
                            – Jacob Groundwater
                            Feb 9 '13 at 20:26










                          • no probs! Issue is solved. cheers
                            – Kiran Ambati
                            Feb 9 '13 at 20:29










                          • This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
                            – modulitos
                            Jun 16 '14 at 20:11
















                          41














                          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.






                          share|improve this answer























                          • Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
                            – Kiran Ambati
                            Feb 9 '13 at 20:11










                          • I have no idea how to do it on Windows, sorry Kiran.
                            – Jacob Groundwater
                            Feb 9 '13 at 20:26










                          • no probs! Issue is solved. cheers
                            – Kiran Ambati
                            Feb 9 '13 at 20:29










                          • This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
                            – modulitos
                            Jun 16 '14 at 20:11














                          41












                          41








                          41






                          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.






                          share|improve this answer














                          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.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Feb 17 '14 at 11:29









                          Dave Liepmann

                          1,09611319




                          1,09611319










                          answered Feb 9 '13 at 20:07









                          Jacob Groundwater

                          4,77912140




                          4,77912140












                          • Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
                            – Kiran Ambati
                            Feb 9 '13 at 20:11










                          • I have no idea how to do it on Windows, sorry Kiran.
                            – Jacob Groundwater
                            Feb 9 '13 at 20:26










                          • no probs! Issue is solved. cheers
                            – Kiran Ambati
                            Feb 9 '13 at 20:29










                          • This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
                            – modulitos
                            Jun 16 '14 at 20:11


















                          • Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
                            – Kiran Ambati
                            Feb 9 '13 at 20:11










                          • I have no idea how to do it on Windows, sorry Kiran.
                            – Jacob Groundwater
                            Feb 9 '13 at 20:26










                          • no probs! Issue is solved. cheers
                            – Kiran Ambati
                            Feb 9 '13 at 20:29










                          • This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
                            – modulitos
                            Jun 16 '14 at 20:11
















                          Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
                          – Kiran Ambati
                          Feb 9 '13 at 20:11




                          Hi Jacob , please can you edit answer and add windows version because I am developing on windows. Thank you
                          – Kiran Ambati
                          Feb 9 '13 at 20:11












                          I have no idea how to do it on Windows, sorry Kiran.
                          – Jacob Groundwater
                          Feb 9 '13 at 20:26




                          I have no idea how to do it on Windows, sorry Kiran.
                          – Jacob Groundwater
                          Feb 9 '13 at 20:26












                          no probs! Issue is solved. cheers
                          – Kiran Ambati
                          Feb 9 '13 at 20:29




                          no probs! Issue is solved. cheers
                          – Kiran Ambati
                          Feb 9 '13 at 20:29












                          This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
                          – modulitos
                          Jun 16 '14 at 20:11




                          This is a great answer, especially when there are multiple node servers running on different ports. I can easily distinguish the process ID's running on each port.
                          – modulitos
                          Jun 16 '14 at 20:11











                          11














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



                          cmd "/C TASKKILL /IM node.exe /F"





                          share|improve this answer



















                          • 1




                            the one that works for me
                            – Anna
                            Sep 1 '18 at 7:40
















                          11














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



                          cmd "/C TASKKILL /IM node.exe /F"





                          share|improve this answer



















                          • 1




                            the one that works for me
                            – Anna
                            Sep 1 '18 at 7:40














                          11












                          11








                          11






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



                          cmd "/C TASKKILL /IM node.exe /F"





                          share|improve this answer














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



                          cmd "/C TASKKILL /IM node.exe /F"






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Apr 19 '18 at 12:24

























                          answered Sep 22 '17 at 21:17









                          Enkode

                          2,56422137




                          2,56422137








                          • 1




                            the one that works for me
                            – Anna
                            Sep 1 '18 at 7:40














                          • 1




                            the one that works for me
                            – Anna
                            Sep 1 '18 at 7:40








                          1




                          1




                          the one that works for me
                          – Anna
                          Sep 1 '18 at 7:40




                          the one that works for me
                          – Anna
                          Sep 1 '18 at 7:40











                          8














                          You can try this:



                          taskkill /IM node.exe -F





                          share|improve this answer


























                            8














                            You can try this:



                            taskkill /IM node.exe -F





                            share|improve this answer
























                              8












                              8








                              8






                              You can try this:



                              taskkill /IM node.exe -F





                              share|improve this answer












                              You can try this:



                              taskkill /IM node.exe -F






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jan 28 '14 at 13:35







                              user1796855






























                                  7














                                  if you want to kill a specific process , you can go to command line route:



                                  ps aux | grep node


                                  to get process id and then
                                  do:



                                  kill -9 PID


                                  and if you want to kill all processes then do:



                                  killall -9 node





                                  share|improve this answer


























                                    7














                                    if you want to kill a specific process , you can go to command line route:



                                    ps aux | grep node


                                    to get process id and then
                                    do:



                                    kill -9 PID


                                    and if you want to kill all processes then do:



                                    killall -9 node





                                    share|improve this answer
























                                      7












                                      7








                                      7






                                      if you want to kill a specific process , you can go to command line route:



                                      ps aux | grep node


                                      to get process id and then
                                      do:



                                      kill -9 PID


                                      and if you want to kill all processes then do:



                                      killall -9 node





                                      share|improve this answer












                                      if you want to kill a specific process , you can go to command line route:



                                      ps aux | grep node


                                      to get process id and then
                                      do:



                                      kill -9 PID


                                      and if you want to kill all processes then do:



                                      killall -9 node






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jun 3 '18 at 6:38









                                      Ali_Hr

                                      15118




                                      15118























                                          2














                                          You could also try:



                                          killall nodejs






                                          share|improve this answer


























                                            2














                                            You could also try:



                                            killall nodejs






                                            share|improve this answer
























                                              2












                                              2








                                              2






                                              You could also try:



                                              killall nodejs






                                              share|improve this answer












                                              You could also try:



                                              killall nodejs







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Jan 4 '17 at 14:11









                                              Digitlimit

                                              9,82944469




                                              9,82944469























                                                  0














                                                  Am Using windows Operating system.



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



                                                  try



                                                  taskkill /im node.exe





                                                  share|improve this answer


























                                                    0














                                                    Am Using windows Operating system.



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



                                                    try



                                                    taskkill /im node.exe





                                                    share|improve this answer
























                                                      0












                                                      0








                                                      0






                                                      Am Using windows Operating system.



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



                                                      try



                                                      taskkill /im node.exe





                                                      share|improve this answer












                                                      Am Using windows Operating system.



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



                                                      try



                                                      taskkill /im node.exe






                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered Jun 21 '17 at 11:54









                                                      Sathya Baman

                                                      1,43422249




                                                      1,43422249























                                                          0














                                                          If you are using windows, follow this:



                                                          1) Open task manager, look for this process: http://prntscr.com/kv3uqx



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



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



                                                          Hope it help somebody!



                                                          Cheers






                                                          share|improve this answer


























                                                            0














                                                            If you are using windows, follow this:



                                                            1) Open task manager, look for this process: http://prntscr.com/kv3uqx



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



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



                                                            Hope it help somebody!



                                                            Cheers






                                                            share|improve this answer
























                                                              0












                                                              0








                                                              0






                                                              If you are using windows, follow this:



                                                              1) Open task manager, look for this process: http://prntscr.com/kv3uqx



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



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



                                                              Hope it help somebody!



                                                              Cheers






                                                              share|improve this answer












                                                              If you are using windows, follow this:



                                                              1) Open task manager, look for this process: http://prntscr.com/kv3uqx



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



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



                                                              Hope it help somebody!



                                                              Cheers







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Sep 16 '18 at 19:07









                                                              Neil Bannet

                                                              6517




                                                              6517























                                                                  0














                                                                  Use the following command to kill and restart node server from batch file



                                                                      @echo off
                                                                  cd "D:samProjectsNode"
                                                                  taskkill /IM node.exe -F
                                                                  start /min cmd /C "node index.js"
                                                                  goto :EOF





                                                                  share|improve this answer


























                                                                    0














                                                                    Use the following command to kill and restart node server from batch file



                                                                        @echo off
                                                                    cd "D:samProjectsNode"
                                                                    taskkill /IM node.exe -F
                                                                    start /min cmd /C "node index.js"
                                                                    goto :EOF





                                                                    share|improve this answer
























                                                                      0












                                                                      0








                                                                      0






                                                                      Use the following command to kill and restart node server from batch file



                                                                          @echo off
                                                                      cd "D:samProjectsNode"
                                                                      taskkill /IM node.exe -F
                                                                      start /min cmd /C "node index.js"
                                                                      goto :EOF





                                                                      share|improve this answer












                                                                      Use the following command to kill and restart node server from batch file



                                                                          @echo off
                                                                      cd "D:samProjectsNode"
                                                                      taskkill /IM node.exe -F
                                                                      start /min cmd /C "node index.js"
                                                                      goto :EOF






                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered Oct 1 '18 at 13:18









                                                                      Samadhan Virkar

                                                                      12




                                                                      12























                                                                          -2














                                                                          Press in cmd or bash :
                                                                          Ctrl + C






                                                                          share|improve this answer


























                                                                            -2














                                                                            Press in cmd or bash :
                                                                            Ctrl + C






                                                                            share|improve this answer
























                                                                              -2












                                                                              -2








                                                                              -2






                                                                              Press in cmd or bash :
                                                                              Ctrl + C






                                                                              share|improve this answer












                                                                              Press in cmd or bash :
                                                                              Ctrl + C







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered Nov 24 '17 at 6:47









                                                                              Altynbek S.

                                                                              1




                                                                              1






























                                                                                  draft saved

                                                                                  draft discarded




















































                                                                                  Thanks for contributing an answer to Stack Overflow!


                                                                                  • Please be sure to answer the question. Provide details and share your research!

                                                                                  But avoid



                                                                                  • Asking for help, clarification, or responding to other answers.

                                                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                                                  To learn more, see our tips on writing great answers.





                                                                                  Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                  Please pay close attention to the following guidance:


                                                                                  • Please be sure to answer the question. Provide details and share your research!

                                                                                  But avoid



                                                                                  • Asking for help, clarification, or responding to other answers.

                                                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                                                  To learn more, see our tips on writing great answers.




                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function () {
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14790910%2fstop-all-instances-of-node-js-server%23new-answer', 'question_page');
                                                                                  }
                                                                                  );

                                                                                  Post as a guest















                                                                                  Required, but never shown





















































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown

































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown







                                                                                  Popular posts from this blog

                                                                                  What visual should I use to simply compare current year value vs last year in Power BI desktop

                                                                                  Alexandru Averescu

                                                                                  Trompette piccolo