Premature end of script headers: index.php, mod_fcgid: read data timeout in 61 seconds
Asked Answered
A

8

22

I wrote a simple crawling script (in php) at localhost (with 4 variations). All of them worked fine at localhost. But when I made move them to shared hosting, two of them worked others gave internal server error. I looked at error_log and I saw these line:

[Wed Jan 23 22:01:02 2013] [warn] [client ***] mod_fcgid: read data timeout in 61 seconds
[Wed Jan 23 22:01:02 2013] [error] [client ***] Premature end of script headers: index.php

I searched but I couldn't find any useful result. What is related to these errors? Any ideas?

Alboin answered 23/1, 2013 at 20:16 Comment(0)
S
46

If you can access Linux server please edit /etc/httpd/conf.d/fcgid.conf file with vim.
Change FcgidIOTimeout 45 to FcgidIOTimeout 600.
Restart Apache.
Then Fast CGI timeout will be solved.

Scherzo answered 10/4, 2013 at 16:31 Comment(7)
This is the answer to life, universe, weird timeouts! It should be the accepted one.Desiccator
@Desiccator hilaariousss :DAfghani
Would become crazy if this answer was not on stack ! ThanksHorseleech
600 seconds is 10 minutes. If you've a script that's taking this long it'll probably timeout elsewhere too (particularly the user themselves).Enrol
Crazy question for you: what if the config defined both FcgidMaxRequestLen and FcgidBusyTimeout, but not * FcgidIOTimeout*? Is there a default value if it is not defined?Swartz
Also, FcgidBusyTimeout 1234 ## Should Match PHP: max_execution_timeCaroncarotene
Is it possible to set different timeout for different directory?Grateful
E
2

I had this problem on a MediaTemple Grid instance with a Drupal7 install; turns out it was being caused by FastCGI; switching to normal / stable CGI seems to have fixed the issue.

Enzymolysis answered 11/6, 2014 at 18:37 Comment(1)
my site on Mediatemple too and that also fixed itExcuse
P
2

If you're using virtual hosts (in my case i've ispconfig) you need to do changes in virtual host config files. These files are under /etc/httpd/conf/sites-available for each virtual host. Just edit your desired config file, locate IPCCommTimeout and set current value to a higher number. You may need to do this change for both variables in same config file in case you have regular and SSL sites.

Puling answered 14/12, 2015 at 8:42 Comment(0)
E
0

read data timeout in 61 seconds

They timed out. It's likely your execution time is set to 60 seconds. So at 61 seconds, the process was killed and therefore had a premature end.

You can adjust your timeout (not recommended) or run the script through another source (recommended).

Elissaelita answered 23/1, 2013 at 20:17 Comment(2)
I'd downvote, the answer isn't useful at all and it doesn't say what timeout timeouted. My execution time is at 150 seconds and it still times out at 31.Desiccator
The question focused on what caused the error not how to fix. To your question, and downvote, considering the message was thrown by mod_fcgid you should adjust the FastCGI timeout. I'd start there as trante's answer explains more about how.Elissaelita
D
0

Essentially your scripts are running too long for the server configuration. mod_fcgid is waiting for php to respond, and its set to give up after 61 seconds. Since this shared hosting, you may not be allowed to change it.

This is not something that should be run via browser/web server anyway. Write it as a console script.

Dynamiter answered 23/1, 2013 at 20:19 Comment(0)
C
0

mod_cfgid introduces other time limits besides PHP's max_execution_time while executing php scripts. Whichever comes first "wins".

As far as I can see, there are numerous time limit configuration items that mod_cfgid considers, and I'm not the expert to tell which one does which, but at least in our case adding the following line

IPCCommTimeout  9999

in the fcgid.conf solved our unexpected timeout problems.

Common answered 8/3, 2015 at 11:41 Comment(0)
C
-1

If any problem involve with mod_fcgid like below: _mod_fcgid: read data timeout in XX seconds _mod_fcgid: can't apply process slot for

Please fix these issues with priority:

_Increasing the memory limit of php (default 128M, up to 256, 384, ... then restart apache anh check it again)
_Increasing the time out of FCGI, but not need if above is ok
Charlotte answered 5/9, 2014 at 4:42 Comment(0)
B
-1

Increase the max_execution_time value, i.e.:

<?php
ini_set('max_execution_time', 300); # 5 minutes
...
Bergeman answered 9/3, 2020 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.