[PHP-FPM] WARNING: [pool www] server reached pm.max_children setting (30), consider raising it
My WordPress site (Nginx + PHP-FPM) was frequently causing Bad Gateway on the Admin page.
Nginx error log
tail -F /var/log/nginx/codenote.net/error.log [error] 3029#0: *12410 connect() to unix:/var/run/php-fpm/www.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 185.11.147.17, server: codenote.net, request: "POST /xmlrpc.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/www.sock:", host: "codenote.net"
PHP-FPM error log
tail -F /var/log/php-fpm/error.log WARNING: [pool www] server reached pm.max_children setting (30), consider raising it
As written in the error log, we’ve reached the upper limit of the pm.max_children setting value, so let’s increase the setting value to solve this.
# vim /etc/php-fpm.d/www.conf
# We've reached the limit at 30, so let's arbitrarily raise it to 50
pm.max_children = 50
After changing the setting, reload PHP-FPM to apply the configuration.
service php-fpm reload
Monitor the error log again with tail -F /var/log/php-fpm/error.log, and if the WARNING message is no longer displayed, the problem should be resolved.
If the WARNING message is still appearing, continue to increase pm.max_children to 60, 70, etc. until the message stops appearing.
That’s all from the Gemba.