Top Nav

MariaDB on CentOS 7 – “Error in accept: Too many open files”

By default is seems the soft and hard open files limits on MariaDB in CentOS 7 are 1024 and 4096 respectfully. You can see these limits by first getting the process ID:

And then looking at the limits in the proc filesystem:

You’ll see something like this:

Notice the numbers for “Max open files”.

If you run into problems with MariaDB failing and you see errors like this in the log:

Then you need to increase the open files limits by editing:

and adding this line:

to the “[Service]” section. Then reload the systemctl daemon:

and restart the MariaDB service:

Now the limit will be increased.  For example:

UPDATE: We’ve seen similar problems with nginx. The solution is similar … increase the limits for the nginx service.

UPDATE: As noted by Bastiaan Welmers in the comments, it better to copy the service control file then to edit:


As describe here:

Create an override file with:


Put the modified settings in the override file:

Reload systemd config:

And restart mariadb:


On server with Plesk, view the current open files limit with:


On Ubuntu 22 and possibly other environments some additional steps were necessary to the limit.

The kernel contains a compiled default upper limit for open files. The limit can be shown with:

Ubuntu 22 sets the limit to 1048576. The limit can be increased on the fly with:

or to change permanently:

For Apache, the upper limit may be set to 8192 with this line:


The line may be commented out in which case the 8192 default limit is applied. To change, uncomment and set desired value.