Linux Too Many Open Files Runbook: Triaging File Descriptor Exhaustion & Socket Congestion
Practical runbook for resolving 'Too many open files' outages on Linux: inspecting system-wide fs.file-max, tuning per-process ulimit limits, finding unlinked open files with lsof, and reclaiming socket leaks.
Authored by: Vibe DevOps · Published: 11/6/2026
The dreaded "Too many open files" error brings production microservices and reverse proxies to a dead halt. This practical runbook covers 18 essential commands across 6 triage stages to diagnose File Descriptor leaks, resolve socket exhaustion, and apply online limit adjustments.
1. System-Wide File Descriptor Inspection
cat /proc/sys/fs/file-nr
sysctl fs.file-max
lsof -b +L1
cat /proc/sys/fs/file-nr: Inspect allocated, free, and maximum kernel file descriptors to differentiate system-wide exhaustion (ENFILE) from per-process limits (EMFILE).sysctl fs.file-max: Check the global kernel file descriptor ceiling.lsof -b +L1: Identify unlinked open files holding onto descriptors and disk space without blocking on locks.
2. Pinpointing FD-Heavy Processes
ls /proc/<pid>/fd | wc -l
prlimit --pid <pid> --nofile
pidstat -v 1 3
3. Categorizing Descriptors (Sockets, Pipes, Disk Files)
ls -l /proc/<pid>/fd | grep sock
cat /proc/<pid>/fdinfo/<fd>
lsof -p <pid> -a -i TCP
4. Socket Exhaustion & Conntrack Triage
ss -s
ss -tan state time-wait
conntrack -C
5. Online Limit Expansion Without Restarts
sudo prlimit -p <pid> --nofile=65535
sudo sysctl -w fs.file-max=2097152
ulimit -n 65535
6. Permanent Hardening via systemd and PAM
cat /proc/<pid>/limits
sudo systemctl edit <service>
cat /etc/security/limits.conf
Remember that systemd units bypass PAM limits.conf entirely; always configure LimitNOFILE=65535 inside systemd override drop-ins.
💡 Team Storage & Usage Tips
Store the vector PDF in your internal team repository (Notion, Confluence) or print it out in A4 format next to your workstation for rapid troubleshooting during midnight production outages.