connect() to unix:/run/php-fpm/www.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 1

Linux (in my case AWS Linux 2 / Centos 7)has some setting issues while connecting to the socket.

Redis, MySQL, PHP-fpm connected by socket has this issue.

The default value is 128 = connections by a socket. During high load or performance test you will have an issue like this in the Nginx log:

2020/06/30 20:00:00 [error] 10441#0: *191619 connect() to unix:/run/php-fpm/www.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 173.00.00.195, server: example.com, request: "GET /test.html HTTP/1.1", upstream:...

Check that the operating system limit allows for above value.

Run:

sysctl net.core.somaxconn

Should display value 128 or higher

Image for post
Image for post

Increase this value by running the following command.

echo "net.core.somaxconn=65536" >> /etc/sysctl.conf
sysctl -p

Restart problem service: mysql, php-fpm, redis

 shudo service php-fpm restart

Written by

Magento/APP Cloud Architect. Melting metal server infrastructure into cloud solutions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store