How I fixed 504 Gateway Timeout error on Nginx + PHP-FPM

Today I got 504 Gateway Timeout error while updating my Joomla website and solved this issue by adding “fastcgi_read_timeout 300” into Nginx virtual host:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/www-shar.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_read_timeout 300;
}

I already had request_terminate_timeout option set to 300s in the pool configuration file:

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 300s

But max_execution_time in php.ini was unchanged so it had its default value 30:

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30

There are some manual telling that I should change it as well, but it is not clear is this strictly necessarily and how this option relates to the options described above.

1 Response to How I fixed 504 Gateway Timeout error on Nginx + PHP-FPM

  1. Bikramaditya dhar says:

    thnx a lot.

Leave a Reply

Your email address will not be published. Required fields are marked *