Skip to content

Q&A · Answered

How to fix "too many open files" error on Linux

asked 9 months, 1 week ago 1825 views 1 answer
16

My application crashes with "too many open files" error. How can I increase the file descriptor limit?

1 Answer

One accepted
9

Accepted answer

Not confirmed since it was written, 9 months, 1 week ago

Check current limits

# Check soft limit
ulimit -Sn
# Check hard limit
ulimit -Hn
# Check for specific process
cat /proc/PID/limits

Increase limits temporarily

ulimit -n 65535

Increase limits permanently

# Edit /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
root soft nofile 65535
root hard nofile 65535

# For systemd services, edit service file
[Service]
LimitNOFILE=65535

Your answer

Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.

Shown beside your answer and never checked, so it cannot be a name someone already has here.

No account needed to answer. Sign in instead and it carries your name and earns reputation.