Nginx + php-fpm "504 Gateway Time-out"
If your Nginx + php-fpm returns 502 or 504 Error then you can try following:
If these 2 didn’t work (and you’re still running php-fpm through TCP then check how many connections are open: netstat | grep 9000
. If there are many CLOSE_WAIT
connections then the solution is to set a request_terminate_timeout=30s
in your /etc/php5/fpm/pool.d/www.conf
file (like here).
This will allow killing TCP connections that didn’t close for different reasons after max 30 sec.