Upper limit on inotify watches reached!

Just upgraded a dockercontainer (https://github.com/StefanHoutzager/elixir-dev-anywhere-docker) to
Erlang/OTP 20
Interactive Elixir 1.5.2
Phoenix 1.2.5
At the end of a first day of refactoring / testing I get when I start phoenix.server again:

Setting up watches. Beware: since -r was given, this may take a while!
Failed to watch /stefan/bpm_app; upper limit on inotify watches reached!
Please increase the amount of inotify watches allowed per user via `/proc/sys/fs/inotify/max_user_watches’.

Is this a known bug (is something not properly cleaned up in the os - ubuntu14.04- after stopping phoenix via ctrl-c?) / do I need to configure something?

1 Like

FWIW I’ve had that before because I was using a nodejs-based build tool (Webpack), and it kept running even after Elixir was killed, in some situations.

1 Like
  1. Make sure you shut down unused containers
  2. Make sure in the dev-container everything got shutdown completely when restarting
  3. Make sure your limit is high enough in the container
  4. Make sure your limit is high enough in the host as watches in the container are counted towards the hosts limit.

But yes, this is a known limitation of about all software that makes excessive use of watches. Even your git-gui, an editor in the host or container, all count towards this limit.

A short term solution is to simply edit the file, a long term solution is to create a startup script which increases the limit during boot time. How to do this exactly depends on your hosts distribution. For the container its a matter of putting RUN echo 1000000 > /prox/sys/fx/inotify/max_user_watches


While building the container I got a error about RUN echo 1000000 > /prox/sys/fx/inotify/max_user_watches
file nonexistent
I’m trying with the following now. I have some other things to do now, if the folowing does not work I’ll let you hear some time.
RUN sysctl -w fs.inotify.max_user_watches=1048576

1 Like

Makes totally sense to not work… It was just a guess :wink:


One can find your guess in other dockerfiles (google). My guess I found in some container using FROM ubuntu:14.04 also.
It just might be that you helped me finding the solution. :wink: So please accept my humble thanks, hahaha.

O o
Read-only file system

RUN sysctl -w fs.inotify.max_user_watches=1048576
is not working either. I’ll find something working sometime.

1 Like

I tried to set the value in a running container also. No luck either. Found a “solution”: you have to change the value for the host, for containers it seems not possible. See

If you have changed it for the host you can see the value is changed when you go into the running container

sudo docker run -t -i stefan/phoenix /bin/bash
cat /proc/sys/fs/inotify/max_user_watches