DEV Community

Alexandre Calaça
Alexandre Calaça

Posted on

1

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


Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay