File Table Overflow
Production Risk
HIGH — ENFILE affects all processes on the system, not just the offending one.
ENFILE (errno 23) is returned when the system-wide limit on open file descriptors has been reached. Unlike EMFILE (which is per-process), ENFILE means no more files can be opened by any process on the system.
- 1System-wide open file limit (fs.file-max) exhausted
- 2A runaway process opening millions of file descriptors is affecting the whole system
- 3Very high concurrency on a server with a low file-max setting
Server under heavy load exhausts the system-wide file descriptor table.
# Check current system-wide usage vs limit: cat /proc/sys/fs/file-nr # Output: open_fds unused max_fds
expected output
open: Too many open files in system (ENFILE)
Fix
Increase the system-wide file descriptor limit
WHEN When the system-wide limit is genuinely too low for the workload
# Temporary: sysctl -w fs.file-max=2097152 # Permanent (add to /etc/sysctl.conf): fs.file-max = 2097152
Why this works
fs.file-max controls the maximum number of file descriptors that can be open system-wide. Increase proportionally to available RAM.
✕ Confuse ENFILE with EMFILE
ENFILE is system-wide; EMFILE is per-process. The fix differs: ENFILE needs sysctl; EMFILE needs ulimit or per-process limits.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev