A long request returns 504 Gateway Timeout after 60 seconds
On AlmaLinux, a PHP request that runs longer than 60 seconds ends with 504 Gateway Timeout even when PHP is allowed more time. Apache stops waiting for PHP after 60 seconds, and one command raises that limit.
Symptoms
A page, import, or export that runs longer than 60 seconds stops with 504 Gateway Timeout. The browser shows this message.
Gateway Timeout
The gateway did not receive a timely response from the upstream server or application.Check the domain's error log for the request.
urbestack-domain-log --name example.com --type errorThe log has a line like this one.
[proxy_fcgi:error] [pid 1395:tid 1490] (70007)The timeout specified has expired: [client 203.0.113.10:52404] AH01075: Error dispatching request to : (polling)Cause
Apache passes each PHP request to the site's PHP-FPM pool. Apache's Timeout controls how long it waits for a response.
On AlmaLinux, httpd.conf leaves Timeout unset, so Apache uses its default of 60 seconds. Ubuntu's apache2.conf sets it to 300 seconds.
When a domain's max_execution_time is above 60 seconds, Apache stops waiting before PHP reaches its own limit. The visitor gets 504 Gateway Timeout. This can happen on any AlmaLinux server that uses the Apache configuration shipped with the distribution and allows PHP to run longer than 60 seconds.
Resolution
Set Apache's
Timeoutto at least the longestmax_execution_timeamong the server's sites. The following command sets it to 300 seconds.urbestack-web-server-set --set Timeout=300UrbeStack writes the server-wide Apache settings that urbestack-web-server-set changes to
/etc/httpd/conf.d/zz-urbestack-web-server.conf, which Apache reads after its own configuration files. UrbeStack tests the full Apache configuration before reloading Apache gracefully so requests in progress finish.Check the configured value.
grep Timeout /etc/httpd/conf.d/zz-urbestack-web-server.confOutput Timeout 300Run the long request again. It now finishes or stops at PHP's own limit.
To restore Apache's default, clear the value.
urbestack-web-server-set --clear TimeoutYou can also set PHP's
max_execution_timebelow 60 seconds so PHP stops a long request before Apache does. The following command sets it to 50 seconds.urbestack-domain-set --name example.com --php-setting max_execution_time=50