# A long request returns 504 Gateway Timeout after 60 seconds

UrbeStack sysadmin note about Apache. Last updated 30 Nov 2026.

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

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
```

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.

Check the configured value.

```
grep Timeout /etc/httpd/conf.d/zz-urbestack-web-server.conf
```

```output
Timeout 300
```

Run 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 Timeout
```

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
```

If the problem persists after you follow this note, you can [open a support ticket](https://support.urbestack.com/new?type=support). Including the output of the commands you ran helps support diagnose the problem.
