Too many open files (EMFILE)
The process hit its file-descriptor limit — sockets, files and pipes all count.
Meaning
Each process has a soft limit (often 1024). Busy servers, file watchers and connection leaks exceed it. Node shows EMFILE: too many open files, Java java.io.IOException: Too many open files.
Common causes
- Low default
ulimit -n(1024) - Leaking file handles or sockets (not closed)
- File watchers on huge trees (webpack/jest/nodemon watching node_modules)
- High-concurrency servers
⚡ Quick fix
- Check usage:
ls /proc/<pid>/fd | wc -lvsulimit -n - Raise the limit for the service (systemd
LimitNOFILE) - Fix leaks — close files/sockets, reuse HTTP agents
- Exclude node_modules from watchers
Detailed fix by platform
Linux
- Raise the limit for a systemd service:ini
# sudo systemctl edit myapp [Service] LimitNOFILE=65535
Node.js
- Use
graceful-fsfor bulk file operations and limit concurrency (e.g. p-limit).
How to diagnose
- Count — Open FDs vs limit
- Kind — lsof -p <pid> — files or sockets?
- Leak — Does the count grow over time?
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026