I own and maintain a game called www.settlementfight.com that has random 500 Internal Server Errors that I can’t stop from happening.
The error in the error log is always “premature end of script errors” in whatever page the error was generated on. For example:
[Mon Aug 16 10:55:56 2010] [error] [client ###.###.###.###] Premature end of script headers: army.php, referer: http://www.settlementfight.com/barracks.php
The error occurs infrequently on every page with PHP, seemingly at random.
By every page, I mean every page. Even my Wordpress at Greatplay.net, which previously went for two years without an outage, now experiences intermittent errors. (All my sites are on the same shared server.)
Four different programs – phpBB, MediaWiki, Wordpress, and the Dreamhost default phpMyAdmin – that I have not programmed; all experience this error. So I doubt it is a coding problem, but it could be a database problem.
Everything I have is all on the same MySQL database. Different sites of mine connect through different hostnames.
The error started on July 31, 2010 – the day before I launched my game, so I doubt it is a problem caused by the increased traffic. I first saw it in the Atlanta, Georgia airport. It has occurred constantly since.
The most recent thing I did before the error was installing the phpBB forums, but it ran smoothly a few days after that before error’ing.
There does not appear to be a connection between traffic and the error.
If I put a script in an infinite loop, the error will occur 100% of the time. This seems to indicate a timeout problem.
It is not a permissions thing, all my scripts are set to “755”. I have double checked this.
I am running PHP 5 as CGI.
What should I do?
Log into your server and check the load. Someone (it may be you) may be running CPU intensive software.
16:34:01 up 74 days, 7:05, 3 users, load average: 0.27, 0.38, 0.36
From what I know, that isn’t bad at all. Could it be something else?
Those are excellent load averages. So now I start blaming the database server, of which you have only one that all of your sites use. Have you contacted Support? They’re good at checking for overworked database servers.
Oh, and as a sanity check, I bet if you put a pure .html file (even with images) on there it’ll work fine.
No, but I’ll contact support when I wake up.
Pure .html files with no PHP always work fine.