If you are getting error “Too many open files (24)” then your application/command/script is hitting max open file limit allowed by linux. You need to increase open file limit as below:
Increase limit
Per-User Limit
Open file:
/etc/security/limits.conf
Paste following towards end:
* hard nofile 500000 * soft nofile 500000 root hard nofile 500000 root soft nofile 500000500000 is fair number. I am not sure what is max limit but 999999 (Six-9) worked for me once as far as I remember.
Once you save file, you may need to logout and login again.
pam-limits
I read at many places that an extra step is neede for limit to change for daemon processes. I did not need following yet, but if above changes are not working for you, you may give this a try.
Open
/etc/pam.d/common-session
Add following line:
session required pam_limits.soSystem-Wide Limit
Set this higher than user-limit set above.
Open
/etc/sysctl.conf
Add following:
fs.file-max = 2097152Run:
sysctl -pAbove will increase “total” number of files that can remain open system-wide.
Verify New Limits
Use following command to see max limit of file descriptors:
cat /proc/sys/fs/file-maxHard Limit
ulimit -HnSoft Limit
ulimit -Snif you are logged in as root:
Check limit for other user
Just replace
www-data
by linux username you wish to check limits for:su - www-data -c 'ulimit -aHS' -s '/bin/bash'Check limits of a running process:
Find process-id (PID):
ps aux | grep process-nameSuppose, XXX is PID, then run following commands to check limits:
cat /proc/XXX/limits
Increase “Open Files Limit”. Solution for “Too many open files (24)”
Pages: 1 2
That “nasty” gnome-shell kept having 1024. So searching for more info I found https://bbs.archlinux.org/viewtopic.php?id=208658 where oconnor663 suggested to create /etc/systemd/system.conf.d/nofile.conf with
[Manager]
DefaultLimitNOFILE=65536
So I issued sudo grep -r NOFILE /etc/
/etc/systemd/user.conf:#DefaultLimitNOFILE=
/etc/systemd/system.conf:#DefaultLimitNOFILE=1024:524288
Bingo!
man systemd-user.conf informed me that the default is 1024! So I changed /etc/systemd/user.conf listing
DefaultLimitNOFILE=50000:524288
Let’s see if it fixes it