Fix the Nginx 504 gateway timeout

Posted on February 21, 2014 at 7:47 pm

If you run a Nginx web server you may have already encountered the annoying 504 Gateway Time-out errors. This kind of error messages are generated most probably by the PHP max execution time limit or by the FastCGI read timeout settings.

Try raising max_execution_time parameter in /etc/php5/fpm/php.ini file:

max_execution_time = 600

Then you can change request_terminate_timeout to the same value, edit the file:


And set the request_terminate_timeout value to:

request_terminate_timeout = 600

Edit the fastcgi_read_timeout parameter in Nginx config file:

location ~ \.php$ {
    fastcgi_read_timeout 600;

Now reload Nginx configuration:

/etc/init.d/nginx reload

Reload also PHP5-FPM configuration:

/etc/init.d/php5-fpm reload


Updated on March 26, 2014 at 11:21 am

Receive updates via email

Other Posts

Updated Posts