I am doing Node.js development in Ubuntu and I'm curious if there is a way to quickly stop and restart a node server.

I run this command to start my app:

$ node app.js

When I make changes to app.js I have to restart the server. To stop it I have to use CTRL-C followed by UP and then enter to reissue the startup command.

Is there a faster way to do this? It doesn't seem like much until you're making many minor changes and needing to restart a lot.

  • 3 keystrokes is too much work? May 25, 2012 at 23:49
  • Nice straw man, but I didn't make that statement. I simply asked if there was a quicker way.
    – CatDadCode
    May 26, 2012 at 5:13

2 Answers 2


run it in cycle:

while : ; do node app.js ; done

so every time you'll hit CTRL-C it will end current node and start next one itself.

To end cycle just hold CTRL-C a while or kill from another shell or even close shell session.

  • This only works if SIGINT is trapped by the shell, which is not the case by default. Try it. May 25, 2012 at 22:55
  • I tried it many times. It doesn't work with sleep or echo, but it does work with smth like ssh -N and node.
    – rush
    May 25, 2012 at 23:03

Many servers accept SIGHUP as a signal to reload their configuration. But if this will not work for you a simple alternative is to use Control-O instead of return. That executes this command and then fetches the next command from the history. Try it like this:

echo hello
echo world
[cursor-up twice]
[now press control-O until you get bored]

Works on Bash, I forget how widespread this feature is.

In this case for running node repeatedly you would just alternate Control-C and Control-O.

  • 1
    It will not work, cause u need to stop command at first (node doesn't end itself like echo in your example).
    – rush
    May 25, 2012 at 22:58
  • That's why the instructions above mention that you need to press Control-C. May 26, 2012 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .