Starting a file-watching process on WSL [โ] might lead to the following error:
error.log
01: Unhandled exception. System.IO.IOException: The configured user limit (128)
02: on the number of inotify instances has been reached, or the per-process limit
03: on the number of open file descriptors has been reached.The fix
Run the following commands in your WSL terminal:
01: echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf
02: sudo sysctl -pThe first line permanently increases the number of inotify instances, and the second applies it immediately without needing to restart WSL.
Why this happens
Linux uses a subsystem called inotify to watch for file changes. Every time a tool wants to monitor a directory, for hot-loading, config changes, file syncing, it opnes an inotify instance.
The default kernel limit is 128 instances.
You might have some dev tools using up some of these instances be it started by you or under the hood of these tools.
Note: The fix above sets this permanently in your
/etc/sysctl.conf. For a temporal fix runsudo sysctl fs.inotify.max_user_instances=524288instead