Nodemon: An error "Error: watch ENOSPC"

Created on 20 Oct 2013  ·  56Comments  ·  Source: remy/nodemon

20 Oct 16:40:37 - [nodemon] v0.7.10
20 Oct 16:40:37 - [nodemon] to restart at any time, enter `rs`
20 Oct 16:40:37 - [nodemon] watching: /my/proyect/server
20 Oct 16:40:37 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/usr/lib/node_modules/nodemon/nodemon.js:160:6)
    at ready (/usr/lib/node_modules/nodemon/nodemon.js:49:22)
    at /usr/lib/node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
20 Oct 16:40:37 - [nodemon] reading ignore list
20 Oct 16:40:37 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at fs.watch (fs.js:1076:11)
    at checkTimer (/usr/lib/node_modules/nodemon/nodemon.js:467:27)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

Most helpful comment

The system has a limit to how many files can be watched by a user. You can run out of watches pretty quickly if you have Grunt running with other programs like Dropbox.

The post suggest running this to increase the number of watches that are available.

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

All 56 comments

Version of Node?

Also, can you provide a simple test case script you're using (to test with).

use Node 0.10.21. With any script, generates an error.

Is this the same issue as #144? I can't replicate this on my mac (though I didn't ask what OS you had, but assumed *nix type based on the path in your paste above).

Not the same, are different here is running a single processo. In the other runs on multiple processo, non-cloud

Experienced this error today with multiple apps (express, restify).

NodeJS: v0.10.21
ElementaryOS Version: 0.2 "Luna" ( 64-bit )
Built on: Ubuntu 12.04 ( "Precise" )
Kernel 3.5.0-43-generic

11 Nov 17:32:38 - [nodemon] v0.7.10
11 Nov 17:32:38 - [nodemon] to restart at any time, enter `rs`
...
11 Nov 17:32:38 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/home/.../node_modules/nodemon/nodemon.js:160:6)
    at ready (/home/.../node_modules/nodemon/nodemon.js:49:22)
    at /home/.../node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

reproduce:

npm install nodemon
./node_modules/.bin/nodemon app.js

app.js (from http://nodejs.org/)

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

I got same error with CoffeeScript --watch ./node_modules/.bin/coffee --watch app/

/home/.../node_modules/coffee-script/lib/coffee-script/command.js:334
        throw e;
              ^
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at watchDir (/home/.../node_modules/coffee-script/lib/coffee-script/command.js:299:27)
    at /home/.../node_modules/coffee-script/lib/coffee-script/command.js:102:11
    at Object.oncomplete (fs.js:107:15)

I got the same error with a compound.js project using coffeescript on Ubuntu 13.10 with node 0.10.21

$ nodemon server.coffee

27 Nov 21:40:14 - [nodemon] v0.7.10
27 Nov 21:40:14 - [nodemon] to restart at any time, enter `rs`
27 Nov 21:40:14 - [nodemon] watching: /home/chok/work/edf/bluetic/src
27 Nov 21:40:14 - [nodemon] exception in nodemon killing node
Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Object.watchFileChecker.check (/usr/local/lib/node_modules/nodemon/nodemon.js:160:6)
    at ready (/usr/local/lib/node_modules/nodemon/nodemon.js:49:22)
    at /usr/local/lib/node_modules/nodemon/nodemon.js:63:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

Can someone have a go at this with the dev version of nodemon? I've made a lot of changes and am trying to concentrate my efforts on making sure the new version gets all these issues closed.

You can install using npm install -g nodemon@dev

Works for me now dunno why. Using latest stable nodemon npm version. Also had same issue with coffeescript --watch and this works too now. No node update, just npm install modules and distro updates.

I have the same error but the process stop :

$ nodemon server.coffee 
3 Dec 15:32:42 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

@chok can you run the following (and paste the result) for me in the same directory you're running nodemon:

find . | wc

I'm trying to get an idea what's actually causing this problem.

Here is the result :

$ find . | wc
   7677    7677  542965

Okay, that's 7600 files it's trying to bind watches too.

Can you run tree and put the result in http://pastie.org/ (only because it's going to be massive).

Pastie said it's too large (more than 64kb) and after all I don't like the text at the bottom :p (All your pastes are belong to us. ). I removed some parts specific to my projects. By the way, most of files are, of course, located in node_modules.

You can find it on gist : https://gist.github.com/chok/7774318

Okay, I _think_ this is a problem entirely linked to the number of files being monitored (since you're having to bind to each individual file). I was thinking about ignoring node_modules and .git directories by default, but can you try doing it with the ignore command (assuming you're still running 0.9.x):

nodemon -i node_modules

Of course this shouldn't need to be done every time, I'm just trying to confirm this is the issue.

It doesn't work :(

$ nodemon -i node_modules/ server.coffee 
3 Dec 20:52:32 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

I also try :

$ nodemon -w app/* server.coffee 
3 Dec 20:53:32 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

Can you run the exact same command, but add --dump and send me the response (when you're doing the ignore version).

There is no change :

$ nodemon -i node_modules/ server.coffee  --dump
3 Dec 21:17:18 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

Hmm, sorry, can you stick --dump before your script, it should give me a dump of the config.

I already tried both :(

$ nodemon -i node_modules/ --dump server.coffee 
3 Dec 21:25:35 - [nodemon] v0.9.10
[nodemon] exception in nodemon killing node
[nodemon] Error: watch ENOSPC
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at Function.check (/usr/local/lib/node_modules/nodemon/lib/config/watchable.js:34:6)
    at alternativeCheck (/usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:18:15)
    at /usr/local/lib/node_modules/nodemon/lib/config/checkWatchSupport.js:36:11
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)

Hi. I don't want to sound obtuse, but when I encountered this error I fixed it by increasing max_user_watches on my system. I've been watching this thread to see if something else was going on.

@taylorjbrennan yeah, I know that will fix the issue, but whilst @chok is able to replicate consistently, I'm after a change that will fix nodemon without the user needing to do the max_user_watches io magic.

@remy great, I look forward to seeing it.

@chok can you try this again with [email protected] - nodemon now ignores .git and node_modules/**/node_modules by default, so the number of watches should be significantly lower (I'll reopen if this is still an issue).

I'm also going to try to detect the watch ENOSPC error and echo out a message about increasing max_user_watches. Not ideal, but nothing more that I can really do.

I haven't this message anymore :) but now I have the problem explained in #245

I just had this issue and it was a problem of too many files open on the system. (Sublime Text loves to open lots of files if you let it)

As soon as I open a directory with many files in Sublime 2 nodemon doesn't work anymore and spits out the referenced error. I was only able to work around that by not using Sublimes "open folder" feature. Thank you for the hint @eyce9000.

@timtips same with sublimetext3 and nodemon v1.3.1

@baio can you double check that. There is no [email protected] - there's a pre-release @1.3.0-1 - but that isn't under production in npm (can you also confirm your npm version)?

He can close this bug? As new versions of nodemon and nodejs, have been solved this problem, although I could not say this entirely solved. It can be said that no longer occurs frequently.

@alejonext can you try with npm install -g nodemon@dev - I've made quite a few changes that aren't in 1.2.1.

The error actually means "Error NO disk SPaCe" - but I think it's linked to the number of files being monitored, which should be reduced down via changes to the watching code...

@remy Works perfect :) thanks for your work!!!!

Sweet. There'll be a stable release of 1.3.0 to npm likely this week with a bunch of bug fixes too.

@remy astonished with response time. Thanks!

@remy
exception in nodemon killing node
Error: watch ENOSPC
at errnoException (fs.js:1030:11)
at FSWatcher.start (fs.js:1062:11)
at Object.fs.watch (fs.js:1087:11)

node v0.10.33
OS: Linux ubuntu

I've fixed this with this command https://github.com/ember-cli/ember-cli/issues/1240#issuecomment-47855317

but is updating the package the recommended way?

I'm wondering why it got like this in the first place. I'm using node version manager with
node 0.12.0
npm 2.7.0
ember 0.2.0

The system has a limit to how many files can be watched by a user. You can run out of watches pretty quickly if you have Grunt running with other programs like Dropbox.

The post suggest running this to increase the number of watches that are available.

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

I'm having this issue with "nodemon": "^1.4.1" and "node": "0.12.7" :disappointed:

Please try with #625

On Tue, 8 Sep 2015 16:20 Wesley Queiroz [email protected] wrote:

I'm having this issue with "nodemon": "^1.4.1" and "node": "0.12.7" [image:
:disappointed:]


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

Tried with alpha but still getting ENOSPC...
My sysctl.conf has fs.inotify.max_user_watches=10000.
If I change it to 524288 it works, but in my "dev-server" I'll not able to change it.

How many files are you trying to watch? i.e. how many are under your
working directory?

On Tue, 8 Sep 2015 at 17:37 Wesley Queiroz [email protected] wrote:

Tried with alpha but still getting ENOSPC...
My sysctl.conf has fs.inotify.max_user_watches=10000.
If I change it to 524288 it works, but in my "dev-server" I'll not able
to change it.


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

Not many, 30 at max.
But i think nodemon is trying to watch node_modules at the root of the project.
Below is the config passed to nodemon (I'm using it as a node module):

nodemon({
    script: 'server/server.js',
    watch: [
        'server/',
        'common/'
    ],
    ext: 'js json coffee'
});

the server folder has:
7 coffee files
5 json files
and the common folder has just 1 json file...

Yeah...so run find . | wc -l and what does that number give you? Though, it's supposed to ignore node_modules by default, it's possible it's not being taken into consideration.

Running find . | wc -l on the root of the project gives me 18266 but when I remove node_modules and bower_components gives just 320.

Okay, so I think that the watch _is_ including the node_modules - this is part of the #625 refactor and needs to be fixed.

@wesleycoder can you try with the latest nodemon@dev (it should be version 1.5.0-alpha4) and run with DEBUG=nodemon <your normal nodemon command> then paste up the full output.

Whoa!
It works!
No errors!
Thanks!

This might be because of your system reach out of user can watch files. you can use the following command line in ubuntu
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
or try
npm dedupe

Ref to this stackoverflow

@ankibalyan @uttampanara

it works !
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

works for me too !
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Same here ! :+1:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Run this command

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

Another possible solution is to add a nodemon.json configuration file in your root folder and specify ignore patterns for example:
nodemon.json

{
  "ignore": [
    "*.test.js", 
    "dist/*"
  ]
}
  • Note that by default .git, node_modules, bower_components, .nyc_output, coverage and .sass-cache are ignored so you don't need to add them to your configuration.

The fs notify trick doesn't seem to work on a docker container... at least not Alpine 3.8, I get the same ENOSPC error. It's becoming more important as tools get deprecated and we still need to maintain legacy products

Was this page helpful?
0 / 5 - 0 ratings