My website exits (error 500) if a script takes more than 60 sec to be executed, but i don't understand why.
Phpinfo:
max_execution_time = 600
max_input_time = 600
In my httpd.conf file:
timeout = 600
So i don't get how to increase this parameter.
I found in my phpinfo (but i have no idea if it's related or not):
default_socket_timeout = 60
mysql.connect_timeout = 60
I think the mysql.connect_timeout is not related at all (i got the error on a page with a sleep(65); only...)
I finaly found the answer !
I will share the answer since i think it may help someone else !
I found in the apache error_log the following :
[Tue Jul 09 15:17:47 2013] [warn] [client 212.198.111.252] mod_fcgid: read data timeout in 45 seconds
[Tue Jul 09 15:17:47 2013] [error] [client 212.198.111.252] Premature end of script headers: test_max_execution.php
I then modified a file located in /etc/httpd/conf.d/ named fcgid.conf
I increased 3 parameters (FcgidIOtimeout, FcgidIdleTimeout & FcgidConnectTimeout) and everything seems to work properly now !
Have a nice day and thank you for paying attention to my question !
Frederic
Have a look at…
PHP set_time_limit()
PHP Runtime Configuration
…and:
MySQL server has gone away - in exactly 60 seconds
Happy reading :-)
Related
I am trying to do a massive select * { insert into..} on a php page using xampp (v 5.5.30) on windows (64bit, 4 Gb ram).
After a few minutes I however get either two error messages:
A) "the connection was reset" in the browsers, or sometimes:
B) "mysql_query(): (HY000/2008): Out of memory..." during the insertion query.
On both occasions the PHP script itself is halted even using the directive:
ignore_user_abort(true);
I can't figure out why this is happening. Things I tried so for:
1) added in my apache config file:
<IfModule mpm_winnt_module> ThreadStackSize 8388608 </IfModule> because in the error log I noticed the line at the time of the connection reset:
[Mon Dec 07 13:01:23.540742 2015] [mpm_winnt:notice] [pid 2344:tid
504] AH00428: Parent: child process 4036 exited with status 3221225477
-- Restarting.
[Mon Dec 07 12:09:39.584814 2015] [mpm_winnt:notice] [pid 1684:tid
528] AH00354: Child: Starting 150 worker threads.
It seems like this error is linked to my problem in some way. Changing the config file however did not help and the error still appears.
2) Changed php ini setting:
ini_set("memory_limit","750MB");
3) Removed all mysql cache using:
RESET QUERY CACHE
4) Set PHP timeout:
set_time_limit(60*60);
The error occurs after a few minutes already.
Additional note: the filesize of the table used in the main select-query (mytable.MYD) is 400Mb, of which I only use a few columns of in the select. Once the query is loaded in the PHP memory, before executing the while loop, the memory footprint is 60Mb (using memory_get_usage())
Any idea what I can do to solve this?
thanks
You have to set execution time also.
set execution time to 0,it is functionally equivalent to turning the execution limit off completely:
ini_set('max_execution_time', 0);
Hope it will solve your problem
I am getting 2 errors as mentioned below.
[Fri Jan 09 04:10:23 2015] [warn] [client 188.165.15.22] mod_fcgid: read data timeout in 31 seconds
[Fri Jan 09 04:10:23 2015] [error] [client 188.165.15.22] Premature end of script headers: index.php
I checked this Premature end of script headers: index.php, mod_fcgid: read data timeout in 61 seconds also. But I do not have any file like /etc/httpd/conf.d/fcgid.conf to edit.
Does anybody have any idea?
I don't think that there might be any issue with php script as it as been working fine from past 1 year. Now all of sudden it has stopped working.
My Apache version is 2.2.22 and PHP Version 5.3.10-1ubuntu3.13
Content of fcgid.conf:
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
FcgidConnectTimeout 20
FcgidIOTimeout 2000
</IfModule>
You can increase the timeout as indicated in the other post:
FcgidIOTimeout 600
But since you are on Ubuntu, you'll find the relevant configuration file here:
/etc/apache2/mods-available/fcgid.conf
For me it was 41 seconds and it was coming from the httpd.conf file of the site
# /etc/apache2/sites-available/website.com.conf
<VirtualHost ipv4:80 [ipv6]:80>
IPCCommTimeout 600 #increased from 41
</VirtualHost>
If you're using FcgidCmdOptions, see answer to this question - mod_fcgid read timeout from pipe, end of script output before headers, multiple versions of PHP . In short - global options are ignored for the program specified in FcgidCmdOptions, so all timeouts have to be configured directly in this instruction.
In my Plesk 11, PHP 5.4.7. Apache/2.4.3 system, when I make cron jobs I get this error from error.log file.
[Tue Mar 19 21:33:18 2013] [warn] [client 88.44.55.66] mod_fcgid: read data timeout in 45 seconds
[Tue Mar 19 21:33:18 2013] [error] [client 88.44.55.66] Premature end of script headers: index.php
So I checked for execution time with this:
echo ini_get('max_execution_time');
I got this value: 1560000
It doesn't seem a timeout problem but I get timeout error?
Answer for the future reference:
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.
That's a mod_fcgid timeout, not a PHP timeout. Take a look at the mod_fcgid documentation to find out how to change it, especially at FcgidIOTimeout.
Cron scripts if build correctly should not be run through apache. Your error shows that you are running into a timeout set by mod_fcgi.
If you access it through http in your cronjob, then it will work as a webpage request and then it may be affected by apache timeout because apache is involved in the process. You can run the php script directly with an absolute path using php interpreter to bypass apache
PHP support is currently set to: run as Fast CGI.
I keep getting these errors in my server log:
mod_fcgid: read data timeout in 45 seconds
Premature end of script headers: index.php
Should be quick fix I think, but I cant find the file to edit. Is this something I can change from Plesk.
Anyone know how to increase the timeout?
In Plesk 12.x and similar go to Web Server Settings and set the following directives:
Additional directives for HTTP & HTTPS
FcgidBusyTimeout 300
FcgidIOTimeout 250
Above lines will change the timeout for scripts that are quiet too long and take too long to execute.
Additional nginx directives
proxy_read_timeout 300;
Above lines will change the proxy timeout.
If the problem persist, increase the values.
See also: Premature end of script headers: index.php, mod_fcgid: read data timeout
Check the screenshots for the guidance:
A solution provided in the forum of Plesk by Parallels staff
Edit the file:
/etc/httpd/conf.d/fcgid.conf
Specifically, change
FcgidIOTimeout 45
to
FcgidIOTimeout 3600
3600 seconds = 1 hour. Should be long enough for most but adjust
upwards if required. I saw one example quoting 7200 seconds in there.
Finally, restart Apache to make the new setting active.
apachectl graceful
Hope it helps
R
My solution to this was to change the PHP settings in the plesk control pannel as per the screenshot.PHP Settings
In the new version of Plesk the fcgid.conf file has moved to:
/etc/apache2/mods-available/fcgid.conf
I had some issues importing an xml file into wordpress. It kept on giving a 500 Internal Error. The error log showed:
[Wed Jul 26 13:18:00.219226 2017] [fcgid:warn] [pid 4751] [client
145.97.205.8:60155] mod_fcgid: read data timeout in 45 seconds
[Wed Jul 26 13:18:00.219505 2017] [fcgid:warn] [pid 4751]
(110)Connection timed out: [client 145.97.205.8:60155] mod_fcgid:
ap_pass_brigade failed in handle_request_ipc function
After following some advice - as the PHP.INI settings made no difference - i changed some settings as advised:
Original:
FcgidIOTimeout 45
To:
FcgidIOTimeout 3600
Also added:
<IfModule mod_fcgid.c>
FcgidMaxRequestsPerProcess 500
<IfModule !mod_fastcgi.c>
Worked like a charm. Thank you for your help.
After changing max_execution_time = 3600 in /etc/php.ini solved my problem.
I've a script which send just a lot of data in json format
by post.
Up to about 10Mb (data are put into a flat file) of data the script works great but
if the load is higher I get from apache 500 Internal Server Error.
I peeped into apache log file I get
[Wed Jan 19 17:26:41 2011] [error] [client ip] Premature end of script headers: index.php
[Wed Jan 19 17:26:41 2011] [debug] mod_deflate.c(615): [client ip] Zlib: Compressed 632 to 385 : URL /index.php
Do you have any idea about it ?
Bye.
Premature end of script headers
This message means the PHP script died before outputing any content-type to apache. If you have ob_* functions activated it could be any error on your PHP script, or a timeout, check your set-time-limit parameter in PHP for timeouts.
Check as well that your exception handling output the correct content type if you want to output an error message.
To check all parameters that can have an impact you must check the timeout parameters and the size limits ones. Here are some of them:
Apache:
LimitRequestBody
PHP:
post_max_size
upload_max_filesize
max_input_time
max_execution_time
and maybe memory_limit as well