Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Running the following server.js:


Works as expected. However, let's throw in an unhandled exception.

   setTimeout(function () {
      throw new Error('User generated fault.');

The error executes after five seconds, and the effect is seemingly the same as ctrl+c if I had merely started the process with $ node server.js.

Now trying to restart the server using $ node server.js I receive the following error:

    Express server listening on port 3000

        throw e; // process.nextTick error, or 'error' event on first tick
    Error: EADDRINUSE, Address already in use

And running $ ps aux | grep node I can see that I still have two node processes running. Killing them allows me to start the server again. But then the process repeats.

This is a problem because I wish to run forever, but doing so causes an infinite death cycle upon the first unhandled exception.

So my questions are:

  1. Do you have any further ideas on why this might occur?
  2. How can I listen for all exceptions and react by kill the process(es)
  3. Is the above a bad approach?

Now the funny part is that this behavior is only found running on my server, and not locally even though given the same server.js file. Consequently this must be a config-issue but I can still not seem to pin-point the issue.

Any help is appreciated.

share|improve this question
I'm seeing the exact same behavior with a Node app we're running. Did you ever resolve this? –  Glen Aug 18 '14 at 18:55
@Glen I did not, sorry. I rebuilt from scratch. So unfortunately I do not have any further input. –  chris Aug 19 '14 at 9:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.