This error occurs because your Linux system restricts the number of inotify watchers. These watchers monitor changes to files or directories in real time, which is essential for development tools to function correctly.
When working on projects involving tools like VS Code, Webpack, Angular, or React, you may encounter the following error:
System limit for number of file watchers reached
How to Increase the File Watcher Limit in Linux
Solution 1: Temporarily Increase the Limit
You can temporarily increase the file watcher limit for the current session.
Step 1: Check the Current Limit
Run the following command to see the current limit:
cat /proc/sys/fs/inotify/max_user_watches
Step 2: Increase the Limit
Use this command to temporarily raise the limit to 524288:
sudo sysctl fs.inotify.max_user_watches=524288
Step 3: Verify the Change
Check if the limit was applied:
cat /proc/sys/fs/inotify/max_user_watches
Note that this change will be reset after a reboot. To make it permanent, follow the next solution.
Solution 2: Permanently Increase the Limit
To make the change persistent across reboots, modify the sysctl configuration.
Step 1: Edit the sysctl Configuration File
Open or create the following file:
sudo nano /etc/sysctl.d/99-inotify.conf
Step 2: Add the Configuration
Add this line to the file:
fs.inotify.max_user_watches=524288
Step 3: Apply the Changes
Run the following command to apply the new settings without rebooting:
sudo sysctl -p /etc/sysctl.d/99-inotify.conf
Solution 3: Handle the Issue for Specific Tools
Some tools like VS Code allow adjusting file watcher settings to reduce load.
Reduce Watcher Usage in VS Code
Open VS Code settings and search for files.watcherExclude
. Add unnecessary directories (like node_modules
) to the exclude list:
"files.watcherExclude": { "**/node_modules": true, "**/dist": true }
Solution 4: Monitor File Watcher Usage
You can track the number of file watchers currently in use by a specific process.
Install the inotify-tools
package:
sudo apt install inotify-tools # On Ubuntu/Debian sudo dnf install inotify-tools # On Fedora
Run the following command to list active watchers:
sudo inotifywatch -r /path/to/project
Thats it.