Linux: File Watching Limits

17th August 2025 · Linux

When developing under Linux with mutliple VSCode editors open, alongside GitKraken, you may get warnings about one, or more, of them being able to watch/update files.

Or, VSCode may fail to follow file updates when changing git branches.

This may be due to the default inotify limits. On Ubuntu 24 they can default to 8129 files and 128 instances.

To check what the limits are, you can run:

cat /proc/sys/fs/inotify/max_user_instances

cat /proc/sys/fs/inotify/max_user_watches

If these are too low, edit the config file:

sudo nano /etc/sysctl.conf

and add the new settings to the end of the file (set the limits appropriate to your system - based on RAM, these run OK on a 64GB system):

###################################################################
# Watches
fs.inotify.max_user_watches=524288
fs.inotify.max_user_instances=8192

And run this to load the changes.

sudo sysctl -p

Once this is done, re-run the initial checks to make sure the changes have been set.

To monitor watch usage, a useful programme is inotify-info at https://github.com/mikesart/inotify-info

This will give you, as an edited sample, info such as:

------------------------------------------------------------------------------
INotify Limits:
  max_queued_events    16,384
  max_user_instances   8,192
  max_user_watches     524,288
------------------------------------------------------------------------------
       Pid Uid        App                            Watches  Instances
   2369650 1000       code                             3,871          2
   2371066 1000       code                             3,032          2
      4518 1000       tail                               517          1
...
   2369645 1000       code                                 1          1
------------------------------------------------------------------------------
Total inotify Watches:   8810
Total inotify Instances: 164