Error: ENOSPC: System limit for number of file watchers reached, watch : Ubuntu 18.04
Andrew Mclaughlin
I received the topic error when starting the react app in the VS Code terminal. I have seen the answers to the topic questions as below.
Temporary Fix: $ sudo sysctl fs.inotify.max_user_watches=524288
$ sudo sysctl -p
Permanent Fix: $ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p
- What actually causes this error? Because I got this when tried to run the app on the next day, which I already ran it yesterday without any problem with the same files?
- Is it possible to occur this other than node modules in Ubuntu?
- If we set this figure, it consumes memory. Is it possible to revert it back to default 8192 again? If not possible, is it limitation in Ubuntu, which need to be addressed in future releases?
2 Answers
- See this answer on stackexchange (not mine)
I suspect the watches from the previous day are still in effect.
It can happen anytime you run out of instances or watches. See previous link. User Oligofren's script and explaination is excellent.
Killing the watching process should work. On my machine exiting VS Code freed up ~470 watches.
from :
do this:
sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
sudo sysctl -p