EMFILE
The error code meaning a process has hit its limit on open file descriptors, printed as "too many open files".
Once the limit is reached every new file or connection fails, so a descriptor leak soon takes a server down.
In more detail
It almost always means files or sockets are being opened and not closed. Raising the limit only postpones the crash; the real fix is closing every handle.
Related terms
- file descriptor — A small number the operating system gives a process for each open file, socket or pipe, used in every later read or write.
- ENFILE — The error code meaning the whole system, not just one process, has run out of open file slots.
- open file limit — The most file descriptors one process may have open at once, set by the operating system and shown by ulimit -n.
- resource leak — A file, socket, timer or other system resource that a program opened and never closed.
Taught in
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services