[OpenSIPS-Users] "too many open files" message in the logs (solved)

Carlos Oliva carlos.oliva at numintec.com
Thu Jun 8 04:37:01 EDT 2017

Hi list:

I had a problem last days and I want to share with you how to solve it,
just in case somebody has the same problem in the future. Devels, maybe is
a good thing to publish in troubleshoting page.

I started to see in a Opensips 1.11.9 log tons of messages with this text:

ERROR:core:handle_new_connect: failed to accept connection(24): Too many
open files

This is a TLS enabled proxy, the vast majority of clients connect to it
using TLS protocol, and the AORs population is about 1000 users.

I thought about kernel FD limits, but checking generic kernel limits seems
the value is too high.

You can check the open files used by opensips TCP main process using
something like "ls -la /proc/PID/fd | wc -l" and check the limit for a
specific process using "cat /proc/PID/limits"

Checking the specific limits of the TCP main process, I can see the limit
for "max open files" is 1024 how is this possible?

The reason is I'm using systemd to launch Opensips, and systemd completely
ignores global kernel limits.

The solution is to put the limit in systemd init file, something like this
inside [service] section:

This is my complete systemd init file, if somebody find it useful.

Description=Opensips Sip server

ExecStartPre=/bin/mkdir -p /var/run/opensips
ExecStartPre=/bin/chmod 775 /var/run/opensips
ExecStartPre=/bin/chown opensips.opensips /var/run/opensips
ExecStartPre=/usr/sbin/opensips -c
ExecStart=/usr/sbin/opensips -P /var/run/opensips/opensips.pid -m 192 -M 16
-u opensips -g opensips


Later do a systemctl daemon-reload and restart opensips service. The new
limits are applied now.

Hope this can help somebody with my problem in the future.


Carlos Oliva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170608/33daaf27/attachment-0001.html>

More information about the Users mailing list