Too many open files (macOS limits) macOS Origin: Platform & cloud OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: macOS Node.js

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.watch on node_modules

⚡ Quick fix

  1. ulimit -n 10240 before running the tool
  2. brew install watchman for Metro/Jest
  3. Find leaks with lsof -p PID | wc -l

Detailed fix by platform

macOS

  1. ulimit -n && launchctl limit maxfiles

How to diagnose

  1. Limit — ulimit -n?
  2. Watchers — Large tree?
  3. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

EMFILE — Too many open files (EMFILE) (Linux)EMFILEfork: Resource temporarily unavailable — macOS: -bash: fork: Resource temporarily unavailable (process limit reached) (macOS)fork: Resource tempor…fork: retry: Resource temporarily unavailable — fork: retry: Resource temporarily unavailable (process/thread limit) (Linux)fork: retry: Resource…Homebrew Cask: It seems there is already an App at — Homebrew: Error: It seems there is already an App at '/Applications/Chrome.app' (macOS)Homebrew Cask: It see…Homebrew: No available formula with the name — Homebrew: Error: No available formula with the name "x". Did you mean ...? (macOS)Homebrew: No availabl…too many open files — Go: accept tcp [::]:8080: accept4: too many open files / open x: too many open files (Go)too many open filesYour Command Line Tools are too outdated — Homebrew: Error: Your Command Line Tools (CLT) are too outdated. Update them from Software Update / Please update to the latest macOS (macOS)Your Command Line Too…zsh: bad CPU type in executable — macOS (Apple Silicon): zsh: bad CPU type in executable: ./tool (macOS)zsh: bad CPU type in …Too many …

Explore the map of this error Full error map →

🧠 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.