33

I hope to restart nodejs on mac osx

$ps aux | grep node
mymac      20215   0.0  0.0  2432768    460 s000  R+    9:49AM   0:00.00 grep node

there is one PID 20215, I try to kill the process

kill -2 20215

it reports

-bash: kill: (20215) - No such process

your comment welcome

3 Answers 3

121

There's no other process containing the keyword "node" in your ps aux output except from grep node. You're trying to kill the process of greping node, and no node process is running, that's why it fails.

Try with

sudo killall node

Or

sudo kill -9 `ps aux | grep node | grep -v grep | awk '{print $2}'`
7
  • 2
    sudo killall node reports:No matching processes were found
    – arachide
    Nov 14, 2013 at 2:12
  • sudo kill -9 ps aux | grep node | tail -1 | awk '{print $2}' reports kill: 20397: No such process
    – arachide
    Nov 14, 2013 at 2:13
  • Just run node whatever.js, there's no node processes running. It will obviously report "No such process", the grep process that appears just ended with grep.
    – jlhonora
    Nov 14, 2013 at 2:13
  • I still see node process with this command: ps -ef | grep node Mar 15, 2017 at 15:28
  • 1
    killall node worked for me like a charm. I did not have to use sudo.
    – shanky
    Jul 14, 2019 at 2:40
1

You can try this:

killall -s KILL node 
1
1

Below command should work

killall node

Reference for more commands

ps commands

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.