Reputation: 1202
I am getting the following error while running my rails app in Ubuntu server
FATAL: Listen error: unable to monitor directories for changes. Visit https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers for info on how to fix this.
I have followed the above GitHub page, but I was unable to write in max_user_watches which were set in 8192 and I want to set that to 524288.
in cat /proc/sys/fs/inotify/max_user_watches
the file was in only read mode.I tried to grant write permissions, but I was getting permission denied error even with root access.
Thanks in Advance!!!
Upvotes: 75
Views: 58223
Reputation: 39
Deleting Gemfile.lock and running 'bundle' in the project directory terminal worked for me.
Upvotes: 1
Reputation: 248
Adding to @mayur-shah's answer,
It worked for me after closing the server and console. So, if you are running rails server/console, close that first.
Upvotes: 0
Reputation: 3449
1000 is way too small, try with 524288 as explained in the wiki page: https://github.com/guard/listen/blob/master/README.md#increasing-the-amount-of-inotify-watchers
Listen uses inotify by default on Linux to monitor directories for changes. It's not uncommon to encounter a system limit on the number of files you can monitor. For example, Ubuntu Lucid's (64bit) inotify limit is set to 8192.
and
If you are running Debian, RedHat, or another similar Linux distribution, run the following in a terminal:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
If you are running ArchLinux, run the following command instead
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
Upvotes: 144
Reputation: 2135
I had this issue during development while running rake
(even with rake -h
), and the solution from https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers did not work, neither did killing the running ruby processes, killing the terminal or even restarting the computer.
To avoid this error I did a new and clean clone of my project and then rake
was working (maybe git clean -fdx
could have worked but I did not try it).
I was running rake version 13.0.3, rails 6.1.1, ruby 2.7.2p137.
Upvotes: 0
Reputation: 12837
This error occurred for me as I had a number of ruby processes currently running that I was unaware of. Just need to terminate them and all is good
Upvotes: 0
Reputation: 942
Just try to execute this from your console
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Hope this will work for you .
References: click here
Upvotes: 32
Reputation: 442
In my case, I just need to turn off the terminal and then start it back again. It works when I try to run rails c
command :)
Upvotes: 7
Reputation: 287
For others who may have this issue. I had a VM disconnect which left the previous rails server running. Running below resolved the issue without needing to up the number of watcher.
kill -9 $(lsof -i tcp:3000 -t)
Upvotes: 7