Saturday, 29 December 2012

NGINX fpm-php 504 Gateway Time-out

I recently encountered the 504 error on NGINX due to a php script fetching data from a slow database server, after 60 seconds of runtime the execution simply timed out... I tried all the suggested solutions I found on forums but they didn't seem to work, the solution that worked here:

Within nginx.conf under the location section and under the server section add the lines starting with fastcgi below:

server {
 location ~ .php$ {
  fastcgi_connect_timeout 60;
  fastcgi_send_timeout 180;
  fastcgi_read_timeout 300;

The timeout values above are all in seconds and may need some tweaking, also remember to check the max_execution_time setting in php.ini if not set within the script itself to extend the default php execution timeout. Remember to restart nginx to load the changes made to your nginx.conf

No comments:

Post a Comment