As I understand it, there are two limits (for the file handles) in Linux
1. At a process level. This is controlled by /etc/security/limits.conf file. I have set this to 64k
2. At the system level. This can be viewed at /proc/sys/fs/file-nr

Inspite of this configuration, I am running out of file handles. Other than monitoring the file /proc/sys/fs/file-nr on a regular basis is there any other way to tell whether the cause of the failure is at process level or system level ?

1 Answer 1


That are a lot of open files for a program. First I would check if the program itself doesn't have some malfunction. Does it close the files properly after it opens it?

Check if there are no soft limits for the process for the users that runs the program:

$ ulimit -Sn

With lsof you can see all the open files for a process.

lsof -p <PID>

Also change the system wide limits. They are in /etc/sysctl.conf (fs.file-max ) it will permanent.

To see the current limits:

cat /proc/sys/fs/file-max


# sysctl fs.file-max
fs.file-max = 1624748

To change system wide limits, will be gone after a reboot.

# sysctl -w fs.file-max=2000000
fs.file-max = 2000000
# sysctl fs.file-max
fs.file-max = 2000000# 
cat /proc/sys/fs/file-max
  • You might add that limits.conf (PAM) doesn't apply to things spawned under systemd. Hard to say these days if folks have systemd unless they specify the distro.
    – Aaron
    Jun 29, 2017 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .