Skip to content
Latchkey

Angular "ENOSPC: System limit for number of file watchers reached" in CI

Angular's watch mode registers an inotify watcher per file. On a Linux runner with a low max_user_watches limit, a large project exhausts the limit and the build or serve fails with ENOSPC, even though disk space is fine.

What this error means

A watch build or ng serve in CI fails with "ENOSPC: System limit for number of file watchers reached", unrelated to actual disk space.

ng
Error: ENOSPC: System limit for number of file watchers reached, watch
'/home/runner/work/app/app/src/app/feature'
    at FSWatcher.<computed> (node:internal/fs/watchers:...)

Common causes

Running a watch build in CI

Watch mode opens an inotify watcher per file; CI does not need watching, so the limit is hit for no benefit.

A low inotify watcher limit on the runner

The kernel fs.inotify.max_user_watches is set low, and a large source tree exceeds it.

How to fix it

Disable watch in CI

  1. Run builds and tests in single-run mode, not watch.
  2. Use --watch=false for ng test and avoid ng serve in CI.
  3. Re-run the job.
Terminal
ng test --watch=false
ng build   # one-shot build does not watch

Raise the watcher limit if watching is required

When a watch is genuinely needed, increase the kernel limit before the step.

Terminal
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

How to prevent it

  • Use one-shot builds and --watch=false tests in CI.
  • Do not run ng serve in pipelines.
  • Raise max_user_watches only on runners that must watch.

Frequently asked questions

What causes ""ENOSPC ... file watchers reached""?
Watch mode opens an inotify watcher per file; CI does not need watching, so the limit is hit for no benefit.
How do I fix "ENOSPC ... file watchers reached"?
Disable watch in CI

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card