DEV Community

Abhinav Kumar
Abhinav Kumar

Posted on • Originally published at abhnv.dev

2

Bump up the number of files your system can monitor for changes

Have you ever been working on a project and realized that project is not being hot-reloaded or re-compiled when you save or have auto-save enabled.

I almost always run into this issue after I have set up a new development environment. It seems like the system just stops monitoring for files. I have only encountered this issue on Linux systems though. Never on Windows or macOS.

After a bit of googling, I found out that the default limit of file watchers count, that Linux systems allow to monitor for filesystem changes is very low. 8192 to be exact. I know that it is very reasonable for a normal user. But not for a development use case. Our workspace's file count is usually upwards of 8192. JavaScript projects? Even more so.

The most common way, applications like VSCode or IntelliJ IDEs monitor filesystem changes on Linux, is inotify. We can query the current limit by running

$ cat /proc/sys/fs/inotify/max_user_watches
Enter fullscreen mode Exit fullscreen mode

If you see a value in thousands, this is your problem. Fortunately, it's very trivial to fix. No kernel compilation needed. 😋

This limit configuration can be set by changing the value of fs.inotify.max_user_watches in /etc/sysctl.conf. You can put it to any number you want but I think ~65000 is a good enough limit. I set it to 65536 because Base 2!

You can do this using:

$ echo fs.inotify.max_user_watches=65536 | sudo tee -a /etc/sysctl.conf
# Then reload the new configuration values
$ sudo sysctl -p
Enter fullscreen mode Exit fullscreen mode

And that's it.

If you just want to set it temporarily, just run

$ sudo sysctl fs.inotify.max_user_watches=65536
$ sudo sysctl -p
Enter fullscreen mode Exit fullscreen mode

You can also put it in your /etc/profile so it will run on every restart. But I feel /etc/sysctl.conf is the better way.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay