There are basically 3 sets of timeouts when dealing with simple NGINX + PHP-FPM stack.
One is PHP engine, which you have already adjusted to unlimited.
Second is PHP-FPM, which is controlled via request_terminate_timeout
in your pool settings. The default is usually like this:
;request_terminate_timeout = 0
Value of 0
would mean that there is no limit set by PHP-FPM itself, so you likely won’t have to adjust that.
Finally, there are NGINX timeouts for FastCGI communication, which are controlled through a couple of directives in your NGINX config. You mostly care about fastcgi_read_timeout
:
If the FastCGI server does not transmit anything within this time, the connection is closed.
You would place it in your PHP handler location, e.g.:
location ~ \.php$ {
...
fastcgi_connect_timeout 600s;
fastcgi_pass ...;
P.S. Don’t confuse “Bad Gateway” (502) and “Gateway Time-out” (504) errors. Those are different errors: the former is for a failure to communicate with PHP-FPM (typically a sign of severe misconfiguration, defunct / not running PHP-FPM process), while the latter is exceeding timeout while communicating with PHP-FPM.