EMFILE
means error maximum files
which indicates that the OS is denying your program to open more file descriptors.
Note that open files in the system include disk files, named pipes, network sockets and devices opened by all processes.
Your operating system specifies the open file limit per process.
To check open file limit of your system use ulimit -a
command. Generally on unix like system it is default to 1024.
If the limitation was 1024, means you/process can open maximum 1024 files. if you exceed this limit means open
, pipe
and dup
system calls will fail and yield EMFILE error.
When you get EMFILE
it mostly indicates the leak in your code. Increasing the ulimit to a higher value is not a good solution in case there is leak in your program.
You should try to find out the cause of leak. Following can be used to debug in unix like operating system :
lsof
meaning list open files
command gives the list of open files. Assume your nodeJS program is having leak so to find out total number of file descriptors opened by your program :
lsof | grep node | wc -l
To find out the file descriptors for sockets, use:
lsof -n -i -P | grep node
Using this we can find out where the leak is and then we can correct it.
EMFILE
error means that the OS is denying your program to open more files/sockets, have a look at: https://mcmap.net/q/110561/-how-do-i-change-the-number-of-open-files-limit-in-linux-closed/511300 – Rectifyforever
. – Nutter