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.

ADVERTISEMENTS

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

www-data
www-data

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 SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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 VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.