Apache web server timeout after 60 seconds

Apache web server timeout after 60 seconds

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The Hidden Layer Behind Apache's 60-Second Timeout

You've configured your httpd.conf to allow 300 seconds and set max_execution_time in PHP to match. Your script runs indefinitely in a local terminal, yet the moment you hit that URL in a browser, the connection dies precisely at the 60-second mark. The absence of error logs is actually the first clue: this isn't an application crash or a PHP syntax error; it's a network-level termination before PHP even finishes parsing its output.

The culprit is almost certainly mod_proxy_balancer or a reverse proxy (like nginx or HAProxy) sitting in front of your Apache instance, rather than Apache itself. In many enterprise hosting environments, particularly on platforms like IBM SoftLayer, the "Apache" you see handling requests isn't the only component involved. A load balancer often sits between your browser and your web server to distribute traffic and handle SSL termination.

When a request hits that front-end proxy, it establishes a TCP connection to the backend Apache server. If the backend takes longer than the proxy's configured timeout, the proxy drops the connection. By default, many load balancers use a 60-second timeout because that is often sufficient for standard web pages but insufficient for long-running PHP scripts. Since no errors are logged on your Apache side, you are seeing a silent ECONNRESET from the client perspective—the browser receives a "connection reset by peer" signal because the proxy severed the link.

To resolve this, you must adjust the timeout settings on the reverse proxy, not just the backend web server.

If you have access to the load balancer configuration, look for directives similar to these:

  • In HAProxy: Check timeout connect, timeout client, and timeout server. Increasing timeout server from 60s to something higher (e.g., 300s or 1min) will allow your backend PHP scripts to complete without interruption.
  • In Nginx: Look for the proxy_connect_timeout, proxy_read_timeout, and proxy_send_timeout directives within the location block serving your application. Ensure these values align with your longest expected execution time.
# Example Nginx configuration snippet
location / {
    proxy_pass http://backend_apache;
    proxy_connect_timeout 10s;
    proxy_read_timeout 300s;      # Must be >= PHP max_execution_time
    proxy_send_timeout 300s;
}

If you do not have direct access to modify the load balancer configuration, you may need to contact your hosting provider's support team. Inform them that you are running long-execution scripts and require an increase in the upstream timeout values on their front-end infrastructure.

On the backend Apache side, your current settings (Timeout 300 and TimeOut 300) are correct for handling requests that take up to five minutes once the connection is established. However, if you are using mod_proxy, Apache also has its own timeout limits that can interfere:

  • ProxyTimeout: This directive sets the maximum time allowed for a proxied request to complete. If this is set lower than your script duration (or left at a default), it will cause the backend connection to close prematurely. You should ensure ProxyTimeout is also set to 300 or higher in your httpd.conf.
# Add this to httpd.conf if using mod_proxy
ProxyTimeout 300

It is also worth noting that set_time_limit(10000) in your PHP code only affects the internal execution timer of the PHP-FPM process or Apache's CGI handler. It does not prevent the network stack from timing out if a reverse proxy is enforcing stricter limits upstream. The fact that your script works in the Command Prompt confirms the logic is sound; the issue is purely infrastructural.

In high-availability setups, relying solely on backend timeouts is a common pitfall. Without adjusting the front-end proxies, even perfectly configured backends will appear to hang or timeout unexpectedly for users. Always verify the complete request path: Browser → Load Balancer → Web Server → Application Logic. Every hop in that chain must be configured to support your longest anticipated execution time.

Our network