Node.js

Fix ENOSPC "System limit for number of file watchers reached"

Linux caps how many files a program can watch for changes. Big projects with a dev server hit the cap. Raise it once and it stays.

macOS has no file watcher limit like this. ENOSPC on a Mac means the disk is full: see Check disk space.

  1. See the current limit
    Terminal · Ubuntu / Debian
    cat /proc/sys/fs/inotify/max_user_watches
  2. Raise the limit and keep it after a restartNeeds sudo
    Terminal · Ubuntu / Debian
    echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/99-file-watchers.conf
    sudo sysctl --system

Check it worked

  1. Check the new limit
    Terminal · Ubuntu / Debian
    cat /proc/sys/fs/inotify/max_user_watches

    It should say 524288. Start your dev server again.

Undo it
  1. Remove the settingNeeds sudo
    Terminal · Ubuntu / Debian
    sudo rm /etc/sysctl.d/99-file-watchers.conf

    The old limit comes back after the next restart.

Windows has no file watcher limit like this. Seeing it in WSL? Run the Linux steps inside WSL.