Quick Fix : Failed to allocate directory watch: Too many open files

For any operation in Linux, we might facing the same issue

Failed to allocate directory watch: Too many open files
The default defined inotify instances (128) has been reached

This happen a lot if we run Kubernetes cluster. 128 is the default number for various Linux distro, for heavy user we need to adjust this values.

Check the current limit

cat /proc/sys/fs/inotify/max_user_instances
128

To update the limit run sysctl command

sudo sysctl fs.inotify.max_user_instances=1200

that command only temporary, the values will revert back once the system restart. To make permanent

echo "fs.inotify.max_user_instances=1200" | sudo tee -a /etc/sysctl.conf

to verify the changes run sudo sysctl -p

Leave a Comment