If you are working on a project using an IDE and suddenly your project is not launching and you see this error:
Error: ENOSPC: System limit for number of file watchers reached, watch '/path/to/your/file'
Don't worry! Its easily solvable and its an error that developers come across quite often.
Why is this happening ?
Linux actually uses a subsystem called inotify
to monitor file changes. Development tools like Webpack, Vite and code editors like VS Code rely heavily on this system to detect any file changes give updates (for example: Reloading the server).
Now each file in your project being watched consumes a small amount of resources, and Linux sets a limit to how much resources it can use in total to prevent excessive resource usage. If you are encountering the ENOSPC File watcher error, it means you have crossed that limit somehow.
Common Triggers
Working on larger projects with many files and dependencies
Running multiple development servers simultaneously
Using multiple IDEs or code editors(like VS Code, Cursor, WebStorm)
Adding new dependencies that increase the number of watched files
Installing a new IDE alongside existing ones
The Solution
Fortunately, solving this issue is straightforward:
Step 1: Check your current limit
First, let's see what your current limit is:
cat /proc/sys/fs/inotify/max_user_watches
This will show you a number (commonly 8192 or 65536).
Step 2: Increase the limit
Edit your sysctl configuration:
sudo nano /etc/sysctl.conf
Press enter and you should see the GNU editor as below:
Now simply add this line to the file
fs.inotify.max_user_watches=524288
Save and exit (in nano: Ctrl+O, Enter, Ctrl+X).
Step 3: Apply the changes
Apply the new settings:
sudo sysctl -p
Step 4: Verify the change
Confirm your new limit:
cat /proc/sys/fs/inotify/max_user_watches
It should now show 524288.
Now try running your project again and hopefully, it solved your issue.
Top comments (0)