≡ Menu

PHP-fpm Too Many Open Files 24 Error (set open file descriptor limit)

I am getting the following error in my /var/log/php7.0-fpm.log file:
        “ERROR: failed to prepare the stderr pipe: Too many open files (24)
How do I fix this problem?

You need to set open file descriptor rlimit for the PHP master process. The default value is system defined but one can increase it as per needs.

php-fpm too many open files error and solution

Edit php-fpm.conf
# vi /etc/php/7.0/fpm/php-fpm.conf
Find rlimit_files
;rlimit_files = 1024
And update it as follows (or as per your need):
rlimit_files = 4096
Save and close the file. Restart php7-0.fpm, run:
# systemctl restart php7.0-fpm

Increase FD limit at the OS level

Find user/group name:
$ grep ^user /etc/php/7.0/fpm/pool.d/www.conf
$ grep ^group /etc/php/7.0/fpm/pool.d/www.conf


Edit /etc/security/limits.conf, enter:
# vi /etc/security/limits.conf
Append as follows (replace user/group name with your actual names):

www-data       soft    nofile  4096
www-data       hard    nofile  4096

Restart required process. Save and close the file. Verify it:
$ su - www-data
To see the hard and soft values, issue the command as follows:
$ ulimit -Hn
$ ulimit -Sn

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 0 comments… add one }

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , ,