Nodemon: listen EADDRINUSE version 1.8.0

Created on 26 Oct 2015  Â·  28Comments  Â·  Source: remy/nodemon

nodemon server.js

  • at first it run normally
  • but when try to resave file/update files it wont rerun

then ctrl+c to stop nodemon
then rerun script again via nodemon server

and it looks like the port is not killed
it gives the error "listen EADDRINUSE"

needs more info stale

Most helpful comment

Try adding the following to your app

process.on('SIGUSR2', () => { process.exit(0); });

All 28 comments

I can confirm that 1.8.0 no longer restarts on file change, however I can use command rs to manually restart it, or ctrl+c to stop it. When restaring it, I do not get any error. So to me, it's just the auto-restart that stopped working with last update to 1.8.0

Same here.

I think line 15 in watch.js file is the problem

@davidgatti that isn't used in 1.8.0 anymore: https://github.com/remy/nodemon/blob/v1.8.0/lib/monitor/watch.js

I'm not completely clear on what people are seeing here. Can someone put together a sample script, and repeatable actions to debug with?

There isn't much to it. start nodemon, change a file in your project, save it, and you will see that nodemon doesn't react to the change.

I downgraded to 1.7.3 and works with no problem.

ps. I go the link to the watch.js file from the release page

Like @davidgatti said; downgrade and it works again. So whatever was added or removed to v 1.8.0 broke it.

+1. Downgrading to 1.7.3 restores file watch functionality.

Confirming the issue with v1.8.0 (no error message displayed)

final edit :

this fixed it

echo fs.inotify.max_user_watches=524298 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

/////////////////////////////////////

To reporduce and then break and then get working again...

//////////confirm everything should work :

Fresh install of express 4.

cd bin && node www

reload 127.0.0.1:3000, 'Welcome to Express' shows up

ctrl C

reload 127.0.0.1:3000, 'Page not found', confirming it shut down

node www

reload 127.0.0.1:3000, 'Welcome to Express' shows up

///////////breaking it :

fresh install of nodemon 1.8.0

Exact same install of Express 4 above.

node NOT listening on port 3000. (confirm with lsof -i :3000, which comes back with nothing)

nodemon

[nodemon] 1.8.0
[nodemon] to restart at any time, enter rs
[nodemon] watching: _._
[nodemon] starting node ./bin/www
[nodemon] Internal watch failed: watch ENOSPC

lsof -i :3000

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 29194 jason 12u IPv6 1167495 0t0 TCP *:3000 (LISTEN)

node bin/www

Port 3000 is already in use

kill 29194

node bin/www

//interestingly, no errors here

reload 127.0.0.1:3000, 'Welcome to Express' shows up

////////////UPDATE///////////////////////

Still playing with it here...

Made a new folder, n, and it contains a single file, s.js

n
--s.js

s.js has only this line :

console.log('test');

Using NVM, I use 4.1.0

nvm use 4.1.0

node s.js  //outputs test

nodemon s.js //[nodemon] Internal watch failed: watch ENOSPC

Using NVM, switch to 0.12.7

nodemon s.js //outputs test!!!

Has something changed with node? Will test more versions. Ruled out issues with flightplan too.

@JasonLough This fixed it for me as well. :+1:

Just ran into this as well.
Node: 4.2.1.
Nodemon: 1.9.1
Results: EADDRINUSE error.
Running lsof -i tcp:<port number> I get back that node is running there. Killing it via PID is the only way to get my server back and running.

Node: 4.2.1
Nodemon: 1.7.3
Results: Everything shuts down correctly.

This issue is currently marked as needs more info. Is there other information we can provide? It looks like there are repro cases and reports going back five months.

Got the same issue -
Very basic app at the moment as I am just creating a new project. The port that is failing for me is the one mongo is listening to.

Node: 4.4.0
Nodemon: 1.9.1
Result: EADDRINUSE

Node: 4.4.0
Nodemon: 1.7.3
Result: expected behvior

If you're able to replicate consistently would it be possible to roll the
version back gently until you find the regression? From there the diff
between versions might be enough to solve this issue.

On Sat, 2 Apr 2016 20:34 VtoCorleone, [email protected] wrote:

Got the same issue -

_Node_: 4.4.0
_Nodemon_: 1.9.1
_Result_: EADDRINUSE

_Node_: 4.4.0
_Nodemon_: 1.7.3
_Result_: expected behvior

—
You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
https://github.com/remy/nodemon/issues/702#issuecomment-204787431

I'm getting this issue (tried it with versions 1.9.0, 1.8.1, and 1.7.3), when used in conjunction with foreman, watchify, and typescript.

My Procfile looks something like this:

# watches all server js
server: PORT=1337 nodemon --delay 2 --ignore client.js --ignore public/_bundle.js
# watches the client and re-browserifys on change
client: watchify client.js -v -o public/_bundle.js
# watches all .ts files and retranspiles them.
typescript: tsc -w

So, tsc should trigger the other two processes to act on their (separate) files. Nodemon starts the first time, but on any subsequent rebuild, I get the EADDRINUSE when it tries to start the server. An rs usually fixes it, but that defeats the purpose of using an auto restart tool in the first place, haha.

Same problem for me
node 6.3.0
nodemon 1.9.2
Thank for your help

Hey,

I can confirm the problem and the solution.

Was in 1.10.2 and got the error randomly.

Now in 1.7.3 and the problem seems gone.

having the same issue with node7.

same issue.

setup
Node 7.8.0
Nodemon 1.11.0

when running
nodemon server/index.js --exec babel-node --presets latest

dies on a few restarts.

Same issue; I thought it was an issue with something else so I just switched to node and kept restarting my docker image on change... that's a pain in the butt. Thanks for letting me know I'm not crazy.

Node: 7.9.0
Nodemon: 1.11.0

same issue.

setup
Node 7.10.0
Nodemon 1.11.0

when running resave file

Same issue.
When running and a file has change in the server

server setup
Node 7.10.0
Nodemon 1.11.0

on local. version 6,10,3 Works
Node 6.10.3
Nodemon 1.11.0

Try adding the following to your app

process.on('SIGUSR2', () => { process.exit(0); });

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3

Problem still exists.

@Nnanyielugo then perhaps you can provide a reproducible example with code, or better yet, a PR to help resolve the problem you're seeing?

@Nnanyielugo I had it today. I think it occured because I had a "zombie" nodemon process running in the background which was fighting with the one I had in my console. Try killing all nodemon processes.

I have been using the same script for almost one year. Now this is happening these days and I don't know why. it happens only in one project. I was using nodemon version 1.17, now I have upgraded to 1.18, it still happens without a reason. I am getting mad

Edit: I restarted the mac, problem resolved.

Try adding the following to your app

process.on('SIGUSR2', () => { process.exit(0); });

This worked, but can you explain to me why it works please? 😄 I tried to research but I was met with similar solutions to paste this in, but not why.

@natasjja Signals with regard to processes reports the occurrence of an exceptional event. For example SIGINT signal is sent when the user types Ctrl-C (https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html#Termination-Signals). The operating system sends these and applications receive them. In some cases the application can respond to the signal, but in others such as SIGKILL it is final and the app will be terminated.

Node passes on signals through event handling (process.on()).

SIGUSR2 is a user-defined (ie. nodemon here) signal that is sent by nodemon upon restart.

As per https://github.com/remy/nodemon#controlling-shutdown-of-your-script, it can be monitored and acted upon in your application. In the example you provided, it explicitly kills the current app process and then nodemon restarts the application cleanly.

Was this page helpful?
0 / 5 - 0 ratings