← Back to Error Index
root@linuxfix:~/too_many_open_files$
Too many open files
File descriptor limit exceeded

Solutions

Prerequisites: Start by updating your system to resolve common issues and ensure the solutions provided below are compatible with your current environment.
check_latest_version && sudo apt update && sudo apt upgrade -y
Check current limits

View file descriptor limits:

ulimit -n
cat /proc/sys/fs/file-max
lsof | wc -l
Increase limits

Raise file descriptor limits:

ulimit -n 4096
echo "* soft nofile 4096" >> /etc/security/limits.conf
Find file leaks

Identify problematic processes:

lsof -p PID
ls -la /proc/PID/fd/
netstat -an | wc -l

What is Too many open files?

The process has reached its limit for the number of file descriptors it can have open simultaneously.

Common scenarios: Applications with file leaks, insufficient limits, or high-connection services.

Common Causes

  • File descriptor leaks
  • Low ulimit settings
  • High connection volume
  • Poor resource management

Debugging Tips

cat /proc/sys/fs/file-nr
lsof | awk '{print $2}' | sort | uniq -c | sort -nr

Prevention

  • Proper file closing
  • Monitor file usage
  • Set appropriate limits
files limits resources performance