OSError: [Errno 24] inotify instance limit reached

Whenever I run any of my streamlit app I get this error

OSError: [Errno 24] inotify instance limit reached

Earlier everything was working fine. But, now nothing works.

I tried to fix it using this- extjs - Error "User limit of inotify watches reached". ExtReact build - Stack Overflow

But it didn’t worked. Any solution?

4 Likes

I faced the same thing. Are there some solutions?

It seems to be strange that problem miss in another server in ubuntu1804 tf222 docker container.
The only difference between the two devices is that the host system problem occurred is ubuntu 1804 and another is ubuntu 20. They are all using docker to manage python environment in the same images.

No solution. So, I just dockerized the streamlit app as a workaround.

Cheerful!! I find a solution after nearly one year.
Other solution just change max_user_watches but not max_user_instances. We should change this config value in similar methods.
Change sysctl.conf in host machine not containers.

sudo nano /etc/sysctl.conf  

Add fs.inotify.max_user_instances = 1100000 to the bottom of file and save changes.
Then use sudo sysctl -p to reload config.

It is really strange that I’m stuck for this tiny difference. Luckily it finally worked.:wink:

2 Likes

change your steamlit run args --server.fileWatcherType none can solve it.

11 Likes

this solution worked for me, in centos 7:

echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system

2 Likes

Thanks @seiriosPlus . I hit into the same problem deploying an app to heroku. I haven’t encountered the problem before with the app - hit into it after updating to streamlit 1.13 & python 3.9.15.

Your solution worked after all other suggestions failed (e.g. <1> can’t update the filesystem on heroku so not possible to update max_user_instances and max_user_watches; <2> Setting fileWatcherType = “none” in the [server] section of config.toml didn’t have any effect :man_shrugging:t3:).

Thanks again for your suggestion!

What are we losing with this, seems like a switch to disable some functionality

Had the same issue, rebooted the app and suddenly it worked…

I documented my solution in the comments on python - OSError: [Errno 28] inotify watch limit reached - Stack Overflow

This appears to be the product of something that VSCode was doing. Here are my comments.

This actually happened to me due to “opening folders” in Visual studio Code. Running on linux. When I started vscode with other streamlit python files open. Then started/Opened a folder project Python/Django from another directory within a larger code directory/repository. However it started adding all the files in the root folder to the watch list.

There are thousands of files in the root from other projects.

~notebooks/work/dev ~notebooks/personal/dev

Each with different projects in them.

The new django projects was ~notebooks/work/dev/djangoproject

Vscode was watching everything all the way down to ~notebooks

Streamlit would then complain. Something akin to too many open file handles.

It took a day or so to realize the culprit. I closed out the folder, and just opened the files from the other streamlit projects and it was fine from then on.

Yes, @Robert_Fleming is correct and is spot on to figuring out the root cause here. VS code eats up a lot of the watched file counts if you add too many folders to your workspace.

works for me! Thank you.

ubuntu 22.04 python3.11 Streamlit, version 1.29.0