apache proxy_fcgi - The timeout specified has expired - Error dispatching request

38,039

Solution 1

Add the following lines into httpd.conf or apache2.conf (depending on your system) file:

Timeout 600
ProxyTimeout 600

and restart apache

sudo /etc/init.d/apache2 restart

Solution 2

I know the question is old but I had this problem with WordPress while doing multiple post deletes and I found it hard to find a solution so I'm putting this down for me (in the future) as much as everyone else with the same problem.

For CentOS 8 ensure you have installed fast cgi and optionally php-fph

yum install mod_fcgid php-fpm

Then if no php-fpm edit:

vi  /etc/httpd/conf.d/fcgid.conf

adding the lines

FcgidIdleTimeout 1200
FcgidProcessLifeTime 1200
FcgidConnectTimeout 1200
FcgidIOTimeout 1200

If php-fpm is installed edit/create:

vi /etc/httpd/conf.modules.d/00-proxy_timeout.conf

and add the lines

Timeout 1200
ProxyTimeout 1200

The restart php-fpm - if installed and httpd

Solution 3

This may help someone else.

If you are using Centos 8, I discovered that the following will resolve the problem - in your php.conf, near where SetHandler is called, add this:

<IfModule !mod_php5.c>
  <IfModule !mod_php7.c>
    # Enable http authorization headers
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

    <FilesMatch \.(php|phar)$>
        SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>
  </IfModule>
</IfModule>

<Proxy "unix:/run/php-fpm/www.sock|fcgi://localhost">
    ProxySet connectiontimeout=600 TimeOut=600
</Proxy>

Solution 4

You can add timeout= to the ProxyPassMatch .

ProxyPassMatch ^/(.+\.php.*)$ fcgi://127.0.0.1:9000/<docroot>/$1 timeout=1800

Have look here .Hope this will help.

Solution 5

I am not sure about the error but it is quite possible that your PHP code application taking a quite longer time than the configured time.i suggest to troubleshoot this using CLI version of PHP.

i can surely say your code stuck in some loop try to use CLI version of PHP it will surely help.

Share:
38,039
TVA van Hesteren
Author by

TVA van Hesteren

I'm a hobbyist who likes to code in PHP, MySQL, C++, Java and jQuery

Updated on July 09, 2022

Comments

  • TVA van Hesteren
    TVA van Hesteren almost 2 years

    I have an application in PHP which returns me:

    [Thu Oct 05 22:10:59.351244 2017] [proxy_fcgi:error] [pid 3733:tid 139869435164416] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:46777] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:16:27.701213 2017] [proxy_fcgi:error] [pid 3732:tid 139869359630080] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:46988] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:21:52.971235 2017] [proxy_fcgi:error] [pid 3733:tid 139869426771712] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47055] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:25:23.561216 2017] [proxy_fcgi:error] [pid 3732:tid 139869351237376] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47115] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:30:47.591237 2017] [proxy_fcgi:error] [pid 3733:tid 139869418379008] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47321] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:39:10.211214 2017] [proxy_fcgi:error] [pid 3733:tid 139869443557120] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47407] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:39:38.591259 2017] [proxy_fcgi:error] [pid 3733:tid 139869376415488] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47412] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:45:13.951238 2017] [proxy_fcgi:error] [pid 3733:tid 139869582505728] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47615] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:50:36.491214 2017] [proxy_fcgi:error] [pid 3732:tid 139869460342528] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47668] AH01075: Error dispatching request to : (polling)
    [Thu Oct 05 22:54:57.661219 2017] [proxy_fcgi:error] [pid 3733:tid 139869326059264] (70007)The timeout specified has expired: [client IPADDRESS HIDDEN:47726] AH01075: Error dispatching request to : (polling)
    

    I think the above messages are - in some way - connected to the following random errors: enter image description here Note, the XMLHttpRequests (AJAX-call) is coming from the same domain and sometimes does not perform with the errors above. However, normally they do execute?

    From what script is this message coming and how can I fix it? There is only one script I can think of which might exceed the default max execution time, however this script is allowed to run longer, using ini_set at the top of the page for the max execution time?

    I have no idea where to look and how to fix this issue

    • E_p
      E_p over 6 years
      Examples of PHP/JS code?
    • Don't Panic
      Don't Panic over 6 years
    • Admin
      Admin over 6 years
      What version of php are you using? Have you tried increasingapache.conf settings TimeOut and ProxyTimeout to a larger value than the ones they already have?
    • TVA van Hesteren
      TVA van Hesteren over 6 years
      It's nothing with the timeout, since it works after a few times. Later on I never get this warning, until a sudden time
  • TVA van Hesteren
    TVA van Hesteren over 6 years
    It's not due to a timeout. It's seems to happen when the server is very busy. Because the script executes fine a few seconds/minutes later?
  • eselskas
    eselskas over 6 years
    Well if the server is busy then most likely it is due to timeout
  • Cary
    Cary about 3 years
    Didn't solve for me. Using apache 2.4 on ubuntu.
  • TGR
    TGR almost 3 years
    Please note the typo before you copy and paste. "imeout" should be "Timeout".