ericclemmons / grunt-express-server

Grunt task for running an Express Server that works great with LiveReload + Watch/Regarde
MIT License
248 stars 64 forks source link

Error: listen EADDRINUSE #97

Closed mindvox closed 8 years ago

mindvox commented 9 years ago

This is really annoying.. I cannot get this to restart on a file change, without throwing an error. Here is the complete output from the console:

>> File "app/core/controllers/client.js" changed.

Running "express:dev" (express) task
Starting background Express server
events.js:85
throw er; // Unhandled 'error' event
          ^
Error: listen EADDRINUSE
    at exports._errnoException (util.js:746:11)
    at Server._listen2 (net.js:1156:14)
    at listen (net.js:1182:10)
    at Server.listen (net.js:1267:5)
    at Object.<anonymous> (/home/karlbateman/Projects/boilerplate/app.js:6:39)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
Stopping Express server

Running "watch" task
Completed in 1.097s at Wed Aug 12 2015 18:50:29 GMT+0100 (BST) - Waiting...

Is there a way of specifying nodemon app from the command option so that the server can restart without this issue. This could make for a good workaround as I have not seen any real solution on the previous issues regarding this error.

Any help with this would be greatly appreciated :smile:

Regards, Karl

jlsutherland commented 8 years ago

Hi @karlbateman,

This issue seems to arise with new versions of node. Processes spun up by newer versions of node don't respond to SIGTERM in the same way that they used to. I've put up a PR that I would expect to merge as soon as I run a few more checks (see #99)---it solves the EADDRINUSE issue. If you'd like, feel free to try it out and follow up!

In the mean time, if you need a quick fix to stop the process: run ps -a | grep node and see what the process id is for your sticky processes. Then kill -9 {pid here}.

(see also #102)

jlsutherland commented 8 years ago

Merged #99