5

I start node.js server has 3000 port by nohup for background running, but now i want to stop the node.js server with 3000 and start again with the same port. How can I stop the process?

i can use this command for get the process to kill;

ps -a","ps -ef |grep nohup

but it return;

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

thanks

2
  • 1
    You can get PID by using pgrep 'nohup' and use kill command. (OR) pgrep 'nohup' | xargs kill (OR) pkill nohup
    – sat
    Commented Aug 6, 2014 at 6:18
  • If I were you I'd just use something like tmux.
    – mshindal
    Commented Aug 6, 2014 at 7:10

1 Answer 1

17

Finally i got an solution for kill the node server which is run under nohup process

by the help of

start server @ background: https://stackoverflow.com/a/4018223/2616818

pid: https://stackoverflow.com/a/14152730

Kill: https://stackoverflow.com/a/8007409/2616818

1.Get the node process id by use

ps -ef | grep "node"
//9500 pts/0  00:00:00 .node.bin

2.Kill the process by

kill 9500
//you can use the PID to kill if not use kill -9 pid

for advanced use forever

4
  • Thanks, but I ran node via "nohup forever server.js" and when I run your command to see process, it tells the pid number, but cannot kill it because its always increasing! please help me Commented Mar 1, 2017 at 2:29
  • use this "kill -9 pid" Commented Mar 1, 2017 at 7:14
  • but pid is always increasing! Commented Mar 2, 2017 at 0:25
  • if its an linux then we can do lsof -i it will list the port which was running Commented Jun 21, 2018 at 12:11

Your Answer

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

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