Introduction
The error message [proxy_fcgi:error] (70007)The timeout specified has expired is a common and frustrating issue encountered by system administrators and developers using the Apache HTTP Server with the mod_proxy_fcgi module. This module is used to proxy requests to a FastCGI application, such as a PHP-FPM service.
Essentially, this error indicates that the Apache web server, acting as a proxy, waited for the backend FastCGI application (e.g., your PHP script) to respond, but the application took longer than the configured time limit. When the timeout is reached, Apache terminates the connection and logs this error, typically resulting in a "504 Gateway Timeout" error for the end user.
Understanding the cause — usually a long-running script, slow network, or an overloaded backend — is the first step to resolving it.
Prerequisites
To follow this tutorial, you will need:
Ubuntu 22.04, 20.04, 18.04 or older server with a sudo non-root user.
Installed Apache, LAMP Stack
Installed PHP
installed Apache2 mod_proxy, proxy_fcgi
,
The error logged in an error log:
[Mon Jun 16 01:44:39.273638 2025] [proxy_fcgi:error] [pid 493649:tid 493689] (70007)The timeout specified has expired: [client 33.133.128.135:39530] AH01075: Error dispatching request to : (polling), referer: https://mysite.com/reports
Causes and Solutions
This timeout error can stem from a few core areas, each requiring a specific configuration adjustment.
Long-Running Backend Scripts
The most frequent cause is a request that genuinely takes a long time to process, often due to complex database queries, file operations, or external API calls.
Increase the ProxyTimeout Directive The ProxyTimeout directive in your Apache configuration controls how long the proxy will wait for a response from the backend. This is often the most direct fix for known long-running processes.
ProxyTimeout 180
You'll typically find this in the VirtualHost or server configuration. The value is in seconds.
Example location of Apache2 config file:/etc/apache2/apache2.conf
request_terminate_timeout = 180
Adjust the PHP-FPM request_terminate_timeout If the PHP script hits its execution limit before Apache's ProxyTimeout, PHP-FPM will terminate the script, which Apache might interpret as a broken connection or timeout.
Example location of PHP-FPM config file:/etc/php/8.0/fpm/php-fpm.conf
Summary
The [proxy_fcgi:error] (70007)The timeout specified has expired error is fundamentally a communication breakdown where the web server has run out of patience waiting for the application server. The resolution requires a methodical approach:
- Identify the culprit: Determine if the script genuinely needs more time or if it's an optimization issue.
- Synchronize Timeouts: Increase Apache's ProxyTimeout to allow more wait time.
- Adjust Backend Timeouts: Ensure the backend application's timeout, like PHP-FPM's request_terminate_timeout, is set to a value equal to or greater than the Apache setting to prevent the backend from prematurely killing the process.
By adjusting these two primary configuration values and addressing underlying load or optimization issues, this persistent timeout error can typically be resolved, ensuring stability for long-running web processes.