Get your free beta license ↗
Websites · Apache

A long request returns 504 Gateway Timeout after 60 seconds

Last updated 30 Nov 2026
Summary

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.

Output
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 error

The log has a line like this one.

Output
[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

  1. Set Apache's Timeout to at least the longest max_execution_time among the server's sites. The following command sets it to 300 seconds.

    urbestack-web-server-set --set Timeout=300
  2. UrbeStack 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.

  3. Check the configured value.

    grep Timeout /etc/httpd/conf.d/zz-urbestack-web-server.conf
    Output
    Timeout 300
  4. Run the long request again. It now finishes or stops at PHP's own limit.

  5. To restore Apache's default, clear the value.

    urbestack-web-server-set --clear Timeout
  6. You can also set PHP's max_execution_time below 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