# 500 error from Mediawiki for first request after an idle period: Premature end of script headers

So I've got a Mediawiki on a subdomain, and until fairly recently everything was fine (if occasionally a little slow). A few weeks ago we started occasionally getting 500 Internal Server errors. Generally it only happens if we haven't visited the site in "a while"... usually hitting refresh (or visiting a different page) will cause the site to load normally.

I've looked at the logs and usually they look like this with FastCGI:

[**date**] [warn] [client *.*.*.*] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[**date**] [error] [client *.*.*.*] Premature end of script headers: index.php
[**date**] [error] [client *.*.*.*] File does not exist: /{directory/url}/internal_error.html


and like this with regular CGI

[**date**] [error] [client *.*.*.*] Premature end of script headers: php72.cgi, referer: http://{url}/index.php?title=Main_Page
[**date**] [error] [client *.*.*.*] File does not exist: /{directory/url}/internal_error.html, referer: {url}/index.php?title=Main_Page


So far we've tried switching which version of PHP we're running, and whether we use CGI or FastCGI. We've tried turning off the .htaccess (limited access to onsite) and had our ISP increase the PHP Memory limit to the max.

Any ideas what might be causing this, or what I can do to troubleshoot? Most everything I've googled has suggested either "trying again later", contacting the webmaster (er, that's me in this case) or are specific to particular ISPs/platform issues. I'm at the end of my rope here.

• I assume that if you are not using FastCGI you don't get the warning about connection reset by peer. – Stephen Ostermiller Oct 29 '18 at 21:37
• @StephenOstermiller Correct, though the two errors are basically the same. – aslum Oct 30 '18 at 13:40