DEV Community

Alexandre Calaça
Alexandre Calaça

Posted on

Error: Unable to monitor directories for changes because iNotify max watches exceeded

Error

 Unable to monitor directories for changes because iNotify max watches exceeded
Enter fullscreen mode Exit fullscreen mode

Context

I got the error after using the following command

rails generate migration addCommentsToProducts
Enter fullscreen mode Exit fullscreen mode

OUtput

Image Context


Solution

As the error message says, in order to solve the issue of inotify max watches being exceeded on Ubuntu, we can increase the number of inotify watchers.

Open a terminal


check the current value of inotify watchers with:

cat /proc/sys/fs/inotify/max_user_watches

Enter fullscreen mode Exit fullscreen mode

Output

Image check the current value of inotify watchers


Increase the number of watches

sudo sysctl fs.inotify.max_user_watches=524288
Enter fullscreen mode Exit fullscreen mode

OUtput

Image Increase the number of watches


Make the change permanent

echo 'fs.inotify.max_user_watches=524288' | sudo tee -a /etc/sysctl.conf
Enter fullscreen mode Exit fullscreen mode

Output

Image Make the change permanent


Apply changes

sudo sysctl -p
Enter fullscreen mode Exit fullscreen mode

Output

Image Apply changes


Try again

Now, you should be able to use the Rails generator or your command without encountering the inotify error.

Enter fullscreen mode Exit fullscreen mode

Output

Image Try again


Done


Top comments (0)