Fixing the 'upper limit on inotify watches reached' Error on Linux

beginner🐧 Linux2026-05-27| Linux (Ubuntu, Debian, Arch, Fedora, RHEL), Node.js, VS Code, Syncthing

Error Message

Failed to watch /path/to/dir; upper limit on inotify watches reached!
#inotify#sysctl#linux-kernel#devops

The 30-Second FixIf you're in a hurry, run these two commands to bump your limit to 524,288. This is the industry standard for development machines and handles even the messiest node_modules folders.

# Apply the fix immediately
sudo sysctl fs.inotify.max_user_watches=524288

# Make the change permanent
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Why Did This Happen?This error usually crashes your party right when you start a dev server like Vite, Webpack, or Nodemon. It also haunts VS Code users working in massive monorepos and anyone running background sync tools like Syncthing.

Failed to watch /path/to/dir; upper limit on inotify watches reached!

Linux uses a subsystem called inotify to track filesystem events. Every time an application monitors a directory for changes, it consumes one "watch." Most Linux distributions ship with a conservative default of 8,192 watches. That sounds like plenty until you realize a standard React or Vue project can easily have 20,000+ files buried in node_modules. When you run out of slots, the kernel simply stops tracking new files, breaking your hot-reloading and IDE features.

Increasing the Limit### 1. Check your current statsFirst, see exactly how many watches your system currently allows:

cat /proc/sys/fs/inotify/max_user_watches

If the number is 8192 and you're working on a modern web app, you've definitely hit the ceiling.

2. Apply a temporary boostNeed to get back to work instantly? Increase the limit without a reboot. This is perfect for testing if the change actually fixes your specific issue.

sudo sysctl fs.inotify.max_user_watches=524288

Keep in mind that this setting vanishes the moment you restart your computer.

3. Make it stick permanentlyTo prevent this error from coming back after a reboot, you need to update your system configuration.

Option A: Update /etc/sysctl.confOpen the file with root privileges:

sudo nano /etc/sysctl.conf

Add this line to the very bottom:

fs.inotify.max_user_watches=524288

Option B: Use a clean config file (Recommended)On modern distros, it's better to keep custom tweaks in /etc/sysctl.d/. It keeps your main config file clean.

echo "fs.inotify.max_user_watches=524288" | sudo tee /etc/sysctl.d/40-max-user-watches.conf
sudo sysctl -p /etc/sysctl.d/40-max-user-watches.conf

Who Is Using All My Watches?Are you curious which app is the biggest resource hog? Run this one-liner to see a list of processes and their approximate watch counts. It's a great way to find "leaky" apps that are monitoring folders they shouldn't.

find /proc/*/fd -lname anon_inode:inotify -printf '%h\n' | cut -d/ -f3 | xargs -I{} -- ps -p {} -o comm= | sort | uniq -c | sort -nr

Will This Slow Down My PC?Not really. Every watch consumes a tiny slice of unswappable kernel memory—roughly 1 KB on 64-bit systems.

If you use all 524,288 watches, you'll lose about 512 MB of RAM. For a developer laptop with 16 GB or 32 GB, that's a rounding error. However, if you're running on a tiny 1 GB VPS, be more conservative and try a limit of 65,536 instead.

Useful Links- inotify(7) manual page - Deep dive into how the kernel handles these events.- VS Code Linux Troubleshooting - Official documentation for this specific error.

Related Error Notes