13

I have a node.js application that uses some socket ports. Sometimes, when I exit the application with Ctrl + C, some kind of node process is left running, still allocating the socket ports. Thus, I cannot restart my application, since it fails to open those ports. When I look the situation with ps, I get the following response:

$ ps

PID TTY           TIME CMD

40454 ttys000    0:00.11 -bash

41643 ttys001    0:00.00 (node)

41741 ttys001    0:00.00 (node)

Trying kill -9 41643 doesn't kill the process. Is it a some kind of unkillable zombie? How can I get rid of those (node)-things blocking my tcp ports?

2 Answers 2

40

I'm not a MAC user, but here is what I use to kill all the available node processes (under linux):

sudo killall -9 node
22

On macOS, it's simply:

sudo killall -9 node

For a lot of the times, sudo is overkill, but in your case, it looks like you might want to try sudo.

2
  • Why the need of -9? Jun 6, 2019 at 18:50
  • 1
    @CaioKawasaki without it, you're not going to pre-emptively kill the node process. Instead, you're letting the processes handle whatever the default signal is, which, there is a slight chance that they will handle the signal without actually killing themselves. Instead, with -9, you're flat out killing the processes, without letting them know.
    – Sal Rahman
    Jun 14, 2019 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.