Published on

Error ENOSPC System limit for number of file watchers reached

Authors

I rebuilt my machine a few days ago and today got an error message I have never seen before.

Error: ENOSPC: System limit for number of file watchers reached,
watch '/home/.../site/src/components/layout.js'

It turns out that the maximum number of files the system can monitor had been reached. Since I am not working on a project larger than I have in the past I not sure why this happened. It turns out that the limit was 8,192, which is fairly low for a software developer. Fortunately, it is easy to increase the limit.

Use the below command to check the current limit.

cat /proc/sys/fs/inotify/max_user_watches

// response
8192

Duckduckgo'ing around I found that 524,288 is a popular number for setting the new limit. To do so:


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

// response
fs.inotify.max_user_watches=524288

Have the Linux kernel read & use the new limit.

sudo sysctl -p

// response

fs.inotify.max_user_watches = 524288

Check the number of watchers again just to be sure.

cat /proc/sys/fs/inotify/max_user_watches

// response
524288

References