GoranStimac.com



Gatsby JS Debugging - Limit of File Watchers Reached on Ubuntu/Debian Linux System

This problem is caused by the way Gatsby.js works, generates static files, and optimizes photos, which easily exceeds the defined Listen limit for the number of files that the Linux OS monitors per directory.

Namely, the Linux OS uses Listen inotify to monitor file changes in directories. Therefore, it is not uncommon to encounter a system limit in the number of files you can monitor. For example, the inotify limit on Ubuntu Lucid (64bit) is set to 8192.

What is the current limit of your system you can find out with command:

cat /proc/sys/fs/inotify/max_user_watches

When the defined limit is not sufficient to track file changes in the directory, you must increase the limit for Listen to work properly.

You can set a new temporary limit with the command:

sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p

If you want to permanently change the Listen limit, use the command:

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

If you still have problems with Listen check the values max_queued_events and max_user_instances.

Related Posts