macOS: Error: EMFILE: too many open files, watch / ulimit: setrlimit failed: invalid argument
A process hit the low default per-process open-file limit on macOS (256 soft in shells), common with file watchers and big builds.
EMFILE: too many open files, watchError: EMFILE: too many open filesulimit: setrlimit failed: invalid argumentToo many open files in system macOSfs.inotify... EMFILE macOS watcher Meaning
Raise the shell limit: ulimit -n 10240 (hard limits via launchctl limit maxfiles). Reduce watchers (exclude node_modules from watchers) and install Watchman for React Native/Jest. Persistent limits use a LaunchDaemon plist for launchctl limit.
Common causes
- Default soft limit 256
- File watchers (webpack, Jest, Metro) on huge trees
- Many sockets/connections
- Leaking file handles
- Node
fs.watchon node_modules
⚡ Quick fix
ulimit -n 10240before running the toolbrew install watchmanfor Metro/Jest- Find leaks with
lsof -p PID | wc -l
Detailed fix by platform
macOS
ulimit -n && launchctl limit maxfiles
How to diagnose
- Limit — ulimit -n?
- Watchers — Large tree?
- Leak — lsof count?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in macOS
- is damaged and can’t be opened macOS: “App” is damaged and can’t be opened. You should move it to the Trash.
- Operation not permitted (macOS privacy) macOS: Operation not permitted — Terminal/app lacks Full Disk Access (TCC privacy protection)
- zsh: command not found: brew macOS: zsh: command not found: brew (Homebrew not on PATH on Apple Silicon)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026