29

I have cloud hosting on Google, it sucks for to be honest but I am trying to get on with it, I installed LAMP stack on a VM and put my website in htdocs. When I try to access my site it gives me request timeout but sometimes it works for 5 minute or so.

When I see apache error logs , it gives me this

075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:55.185819 2015] [proxy_fcgi:error] [pid 4995:tid 140183521683200] (70007)The timeout specified has expired: [client 162.158.255.169:34198] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:55.487458 2015] [core:notice] [pid 2953:tid 140183785137920] AH00052: child pid 4995 exit signal Segmentation fault (11)
[Tue Oct 27 18:12:55.787973 2015] [proxy_fcgi:error] [pid 5063:tid 140183530075904] (70007)The timeout specified has expired: [client 199.27.133.137:13151] AH01075: Error dispatching request to : (polling), referer: http://whichtube.com/watch/g9-4dCeFQng/allama-nasir-abbas-jawab-ali-as-nae-talwar-kayou-na-uthai.html
[Tue Oct 27 18:12:57.542883 2015] [proxy_fcgi:error] [pid 5329:tid 140183521683200] (70007)The timeout specified has expired: [client 173.245.56.198:51348] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:57.976752 2015] [proxy_fcgi:error] [pid 5063:tid 140183479719680] (70007)The timeout specified has expired: [client 173.245.56.198:63779] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:58.993666 2015] [proxy_fcgi:error] [pid 5194:tid 140183496505088] (70007)The timeout specified has expired: [client 162.158.255.141:16226] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:59.196701 2015] [proxy_fcgi:error] [pid 5329:tid 140183513290496] (70007)The timeout specified has expired: [client 173.245.56.198:32819] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:01.462039 2015] [proxy_fcgi:error] [pid 5329:tid 140183504897792] (70007)The timeout specified has expired: [client 199.27.128.166:48057] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:07.518999 2015] [proxy_fcgi:error] [pid 5063:tid 140183471326976] (70007)The timeout specified has expired: [client 173.245.56.198:13694] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:16.804990 2015] [proxy_fcgi:error] [pid 5261:tid 140183513290496] (70007)The timeout specified has expired: [client 199.27.128.134:28694] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:33.055860 2015] [proxy_fcgi:error] [pid 5328:tid 140183236331264] (70007)The timeout specified has expired: [client 39.41.139.220:52154] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:57.391361 2015] [proxy_fcgi:error] [pid 5063:tid 140183521683200] (70007)The timeout specified has expired: [client 39.41.139.220:52029] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:57.552542 2015] [core:notice] [pid 2953:tid 140183785137920] AH00052: child pid 5063 exit signal Segmentation fault (11)

My website is in PHP, I haven't changed anything else other than directory permission, Is there something I am missing ?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
require_once
  • 1,995
  • 3
  • 21
  • 29

7 Answers7

19

I was having the same problem, turns out Apache has module that handles timeouts called mod_reqtimeout

The default value (you won't see it in the default http.conf) is:

RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500

In my case I was uploading a file through a plain HTML form submission, so the file is technically part of the header and the default configuration says that the header will timeout at 20 to 40 seconds. The 20-40 thing is pretty cool because it will timeout at 20 seconds but if 500 bytes are sent in a second, it will add an additional second of wait time until it reaches 40 seconds and then timeout no matter what.

I upload larger files in my website so I added this line to my httpd.conf file:

RequestReadTimeout handshake=0 header=20-600,MinRate=500 body=20,MinRate=500

So as long as my user is sending data at a minimum of 500 bytes/s, the request will not time out until a max. of 600 seconds is reached (better read the documentation, don't quote me on the throughput rate)

It's actually a pretty cool Apache module but not super well known as people recommend to change other apache timeout settings in other similar "The timeout specified has expired:" problems related to PHP-FPM but this problem happens with any post that takes more than 40 seconds to be submitted by default in Apache.

  • The AH01075 error message from `proxy_fcgi` is saying that the request being proxied to php-fpm has timed out, presumably because [ProxyTimeout](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxytimeout) has been exceeded. Are you saying that you see this same error when `RequestReadTimeout` is triggered? I ask because I would instead expect to see something like _"Request body read timeout"_ if `RequestReadTimeout` were involved. – molecularbear Sep 26 '19 at 18:49
  • @molecularbear the exact error I got was: `[Fri May 10 13:19:41.073170 2019] [proxy_fcgi:error] [pid 26964:tid 140276668856064] (70007)The timeout specified has expired: [client 201.17.156.113:2022] AH01075: Error dispatching request to : (reading input brigade), referer: https://siste..` This timeout was caused because the file the user uploaded to my php script (which is sent in the POST headers actually), took longer than the default value so it timed out. – Roberto Ibarra Rabadán Sep 27 '19 at 19:16
  • beware that [`handshake` variable are not available until Apache version 2.4.39](https://httpd.apache.org/docs/2.4/mod/mod_reqtimeout.html) – Christophorus Reyhan Apr 28 '22 at 03:41
10

It appears that your PHP code is taking longer than the configured timeout to complete. When apache loads a PHP page using fcgi it sends the request of to PHP-FPM service to be processed. If PHP-FPM takes too long to respond then you will see this type of timeout. Possible causes are; your PHP code could be stuck in a loop, or waiting on a response from a database that is taking a particularly long time.

To troubleshoot I would use the CLI version of php to see if the script completes in a reasonable amount of time ($ time php /path/to/file.php). There may additional information in the PHP-FPM log (default: /var/log/php-fpm.log).

Tim
  • 2,139
  • 13
  • 18
6

For me a restart of php-fpm did the job. After looking in the log as @varlogtim adviced. The log showed that there was no activity for the last 12 hours...

David
  • 61
  • 1
  • 1
3

I had this problem, too. You may want to looking for a hard-code part and a connection to another unavailable server, in your code. (for example a local IP which is not accessible online).

For mine, I checked php-fpm.log on my server and I found my application is trying to connect to an old server (wrong IP) and it faces with timed out.

Saeed Sepehr
  • 93
  • 1
  • 7
2

I faced this exact problem. I solved the problem by increasing timeout. My OS is AlmaLinux 8.5. Add the following two lines either in your httpd.conf or your virtualhost conf file.

Timeout 600

ProxyTimeout 600

Hasanuzzaman Sattar
  • 592
  • 1
  • 5
  • 20
1

I had the same problem and in my case this solution worked:

  • increase request_terminate_timeout value located in my /etc/php-fpm.d/www.conf file.

Note: This option overrides php max_execution_time ini option and setting a low value for it could make you a lot of troubles because it will override other options and forcefully kill the request if the timeout expires. (If you ask which value to set; it should be max script proccesing time based on your needs but normally 600s(10minutes) or 10m(10minutes) is more than enouph.)

Mojtaba Rezaeian
  • 8,268
  • 8
  • 31
  • 54
-3

I had the same problem on Centos 7 : problem with SELINUX. You can temporary disable SELINUX to check : sudo setenforce 0