It can be quite a problem. This error (ENFILE
) means that either you, or the OS, has too many open file descriptors.
stdin, stdout and stderr are file descriptors; any open file is a file descriptor; any socket you create is a file descriptor as well.
To know your limit of open files, as a user, do:
ulimit -n
To know the limit of the OS, do:
cat /proc/sys/fs/file-max
Generally, it is the user limit which is the problem.
You can try and raise the limit using:
ulimit -n <a greater number here>
but more than likely it won't work. What you need to do is editing /etc/security/limits.conf
of, preferred, create a new file in /etc/security/limits.d
with a relevant name and add these two lines:
theuser soft nofile <somelargenumber>
theuser hard nofile <somelargenumber>
Note that in order for these limits to take effect, the user must log out and login again; if it is a user dedicated to a system service, then restarting this service will do.
Additionally, if you know the PID of the process running your application, you can see the number of currently open file descriptors by issuing the command:
ls /proc/<thepid>/fd|wc -l
If the kernel limit is the problem (very unlikely but who knows) then you'll have to edit /etc/sysctl.conf
and change the proc.sys.fs.file-max
entry, then run sysctl
-- as root
.