ENOSPC: System limit for number of file watchers reached, watch code example

Example 1: system limit for number of file watchers reached

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

Example 2: Error: ENOSPC: System limit for number of file watchers reached

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
# that modifies the file watch limit to max 524,288 which consume approx. 512MB Ram for 64bit.
# reduce that number to consume less memory.

# to see if that did it run
cat /proc/sys/fs/inotify/max_user_watches

# you should see
fs.inotify.max_user_watches=524288

Example 3: Error: ENOSPC: System limit for number of file watchers reached,

Ubuntu

sudo gedit /etc/sysctl.conf

Add a line at the bottom

fs.inotify.max_user_watches=524288

Then save and exit!

sudo sysctl -p

Example 4: unhandledpromiserejectionwarning error enospc system limit for number of file watchers reached watch

# insert the new value into the system config
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

# check that the new value was applied
cat /proc/sys/fs/inotify/max_user_watches

# config variable name (not runnable)
fs.inotify.max_user_watches=524288

Example 5: Internal watch failed: ENOSPC: System limit for number of file watchers reached

echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Example 6: System limit for number of file watchers reached,

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