Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have Apache2 with PHP + PHP-FPM configured according to:

I am writing a script that will take a long time to execute on an internal Vhost, but keep getting timed out, everything runs flawlessly if the script executes in under 30 seconds.

My apache log tells me:

[Wed Apr 17 21:57:23.075175 2013] [proxy_fcgi:error] [pid 9263:tid 140530454267648] (70007)The timeout specified has expired: [client] AH01075: Error dispatching request to :, referer:

When trying to run the script I am given a 503 Service Unavailable after exactly 30 seconds of execution time. Logically this would mean I have a timeout directive or setting set to 30 seconds, but I have these in my Vhost's config:

Timeout 600
<IfModule proxy_module>
    ProxyPassMatch ^/(.*\.php)$ fcgi://$1 timeout=600
    ProxyTimeout 600

(php-fpm is running on port 9001 for me)

I have also tried placing the Timeout and ProxyTimeout in httpd.conf with no difference.

It seems there's another timeout setting somewhere that's specific to mod_proxy_fcgi, but I can't find it. I installed the Apache2 httpd from the official tarball, none of the mods seem to have come with any configuration files.

If anyone can point me in the right direction it would be much appreciated.

share|improve this question

6 Answers 6

up vote 12 down vote accepted

I finally fixed this problem after testing several configuration parameters. I tested the solution twice, removing all previous changes. Only one parameter was needed for me to fix it.

<Proxy fcgi://>
  ProxySet timeout=1800
ProxyPassMatch ^/(.+\.php.*)$ fcgi://<your_path>

I needed to add the Proxy directive to set the timeout to 30 minutes. In some applications, usually when operating database, there are routines that can take more than 10 minutes to execute. I temporary set the timeout to 30 minutes to ensure they finish. Specifically useful when using the installation wizard, which takes too much time (in my humble opinion).

By the way the intial input that helped me to solve this issue was found in the following URL address.

share|improve this answer
Wonderful. This should be ranked higher on google! – karlingen Sep 17 '14 at 6:54
It looks like this broke under recent versions of Apache, AH00526: ProxyPass/<Proxy> and ProxyPassMatch/<ProxyMatch> can't be used altogether with the same worker name – Stewart Adam Jan 24 at 10:15
I have resolved the above by adding a parameter 'timeout=120' at the end of the ProxyPassMatch line. – Stewart Adam Jan 24 at 10:28
@Stewart Adam this was it, please add it as an answer! – Palantir Jun 9 at 8:16
@Palantir glad to hear it! Submitted as answer. – Stewart Adam Jun 11 at 0:54

I wanted to point out that although this answer works great for older versions, it breaks under recent versions of Apache 2.4 with error code AH00526. ProxyPass and ProxyPassMatch or <Proxy> and <ProxyMatch> cannot be used together within the same worker name. This used to function just fine, so don't know if that was changed by design or if it's a bug.

Either way, you can fix this by only using a ProxyPassMatch with parameter 'timeout=120' (or whatever your desired value is), e.g.:

ProxyPassMatch ^/(.*\.php)$ fcgi://$1 timeout=120
share|improve this answer
Took me a bit to catch up with my upvoting duties :D – Palantir Jun 16 at 14:05

We are having the same issue. It's really trivial to recreate - simply create a php script with sleep(60) as the only line. It will always timeout after 30 seconds. Here are some relevant php settings that we use:

php.ini: max_execution_time = 5 max_input_time = 3 memory_limit = 8192M

php-fpm.conf: request_terminate_timeout = 0 request_slowlog_timeout = 0

We have both ProxyTimeout and Timeout set to 600 in the apache config, and are still receiving the following error:

[Thu Apr 25 15:20:11.977250 2013] [proxy_fcgi:error] [pid 21763:tid 140634392327936] (70007)The timeout specified has expired: [client] AH01075: Error dispatching request to :

That's the exact line not edited or redacted in any way (notice that it does not provide much information).

I've turned up debug logging on php-fpm, but it doesn't show anything except for a broken connection (since it's apache thats doing the terminating). I've also turned up debug logging on apache (LogLevel debug trace4), but it only every shows the above message.

I've even gone so far as to dig through the code, and found this in mod_proxy_fcgi.c:

    /* We need SOME kind of timeout here, or virtually anything will
     * cause timeout errors. */
    if (! conn->worker->s->timeout_set) {
        timeout = apr_time_from_sec(30);

that's the only place I could find a hard-coded 30 second timeout. Anyone have any idea if there is a way to set this timeout - "connection Worker" I assume.

We are using apache 2.4.2 and php 5.3.6.


share|improve this answer
StackOverflow is a question/answer format. Please read the FAQ: – tristan Apr 26 '13 at 15:59

Shouldn't that be:

<IfModule mod_proxy.c>

Be sure the php.ini setting max_execution_time is set to 600 also. (check phpinfo() on the live page to make sure you're seeing the actual value used)

As Jenny said, set the php-fpm setting

request_terminate_timeout 610s

(note the s at the end)

There's not much to configure with mod_proxy_fcgi itself, as you can see on the apache page.

Turn on php-fpm debug logging also so you can see where it times out there. (also turn on catch_workers_output)

And turn on debug level logging for the mod_proxy and mod_proxy_fcgi modules since you're using apache 2.4. Very nice feature, turn on just for the modules you need:

If those don't help, post your php-fpm config file.

As a last resort, maybe some daemon is killing long running process?

share|improve this answer

I noted that you are using PHP-FPM. I too use it, but with Apache 2.4.6.

Assuming that the issue has existed for some time, it seems to be that the timeout value for mod_proxy_fcgi is hard coded. I wrote up what I found here

share|improve this answer

Since you've fixed the timout settings in apache, that shouldn't be the issue. The second place to look would be any network equipment, but since you're proxying to your own server, that's also unlikely. So the remaining place to look is at the backend server.

Ih the config file for php-pfm, look for

; This is a hard kill switch on php execution.  It ignores the
; max_execution_time that can be set/changed with php_ini.  Basically
; it avoids timeout issues between apache and php-fpm.

This should be set to the same as, or slightly below, the timeout setting in apache.

share|improve this answer
I've set the request_terminate_timeout to 400, still no change :( I have a feeling that there's something I need to set for mod_proxy_fcgi, but it didn't seem to come with any configuration files. – pyrokinetiq Apr 18 '13 at 23:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.