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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum