How do I catch node.js/express server errors like EADDRINUSE?

The accepted solution did not work for me on nodejs 0.8.22 and express 3.1.0.

This did the trick:

process.on('uncaughtException', function(err) {
    if(err.errno === 'EADDRINUSE')
         console.log(...);
    else
         console.log(err);
    process.exit(1);
});     

Also see Node.js Express app handle startup errors

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)