Linux
Aug 21, 2025 5 min read

Fix "Too many open files" on Linux

Raise the open file descriptor limit the right way — per process, per user, and system-wide.

Problem

bash
accept: too many open files

Root cause

Linux caps the number of file descriptors per process. The default (1024) is far too low for any modern server.

Solution

Check current limit

bash
ulimit -n && cat /proc/$(pgrep -f myapp)/limits | grep 'open files'

Raise for systemd services

ini
# /etc/systemd/system/myapp.service.d/override.conf
[Service]
LimitNOFILE=1048576
bash
sudo systemctl daemon-reload && sudo systemctl restart myapp

Raise per user (login shells)

bash
# /etc/security/limits.d/nofile.conf
*  soft  nofile  1048576
*  hard  nofile  1048576

Frequently asked questions

Related fixes

Weekly digest

One DevOps fix in your inbox each week

Short, practical, no fluff. Real errors, real fixes — straight from production postmortems.