11: Resource temporarily unavailable, while connecting to upstream + Bad Gateway (Nginx)
These errors could be caused by lack of allowed maximum number of socket connections (mostly default is 128). You can view the current limit by executing cat /proc/sys/net/core/somaxconn
and it's highly recommended to increase this limit:
sudo echo "net.core.somaxconn = 65535" | tee -a /etc/sysctl.conf
sudo sysctl -p
And check whether it has changed cat /proc/sys/net/core/somaxconn
.
Also these errors could be caused by lack of number of incoming connections backlog queue (mostly default is 1000). Check the current limit executing cat /proc/sys/net/core/netdev_max_backlog
. It's recommended to increase the limit:
sudo echo "net.core.netdev_max_backlog = 65535" | tee -a /etc/sysctl.conf
sudo sysctl -p
And check whether it has changed cat /proc/sys/net/core/netdev_max_backlog
Note: it's impossible to follow my advice if these troubles appeared on your OpenVZ VPS, because you can't change kernel parameters using this type of virtualization. The better option in this case is trying to use port listening in your php-fpm pool config instead of socket (e.g. listen = 9000). Check your busy ports for finding available one by executing sudo netstat -tunlp
.
you have some mismatch in cfg, in php define listen = /run/php/php7.0-fpm.sock
but nginx try to connect to fastcgi://unix:/var/lib/php7.0-fpm/web3.sock
. Set the same value on both places (php and nginx)