I learned something new about Linux today! I ran into a problem when an OS process opened too many files. It turns out that also prevents opening a new socket while making network connections. The limit for how many files a process can open includes sockets because they are both kernel handles. The default limits were a little low for me so I wanted to raise the limits, not only per process but across the whole system.
To check the limit per process, run ulimit -n
. 1024 in my case.
To change it, add these two lines to /etc/security/limits.conf
:
* soft nofile 4096
* hard nofile 10240
The soft limit is the number files a process can open normally. The hard limit is the maximum amount a user can configure, in case they temporarily need more resources. The first parameter is the user the limit will apply to and a *
can be used to change the limit for all users.
To change the limits for the entire system, add fs.file-max = 1048576
to /etc/sysctl.conf
.
That was a fun one to track down!
Top comments (0)