Premature end of script headers: index.php

I’m being driven mad by internal server errors n- the log reveals the following:

Premature end of script headers: index.php

This is on Drupal 6.11 - the installation has been stable until recently - DH tells me that there have been problems on my shared server, and in addition to this error, I’ve been having horrible performance issues at certain times of day -

I don’t want to be hysterical and then find I’m causing the problem!

Has anyone a clue what this means in practical terms?

my site hits that every so often, and it’s not my fault :wink:

if somebody else on the shared server is hogging resources, your scripts time out and you get that message. i’m currently close to that situation – scripts that normally run in a couple hundred milliseconds are taking as long as 15 seconds (i use php microtime() at the beginning and end of my scripts to see how long they run).

it seems all we can do is to hope the problem people clean up their act or get off the shared server that affects us.

track7 - my dream-hosted site

We are also getting this issue on our principal site:

Also using Drupal 6.11 , which has also been stable until today.

Whats strange though is we are using multi-site drupal (the same drupal core files, for multiple different websites). The other websites load fine, but the principal site doesnt load at all. We’re getting a mixture of 500 (internal server error) and 503 (service temporarily unavailable) errors.

The error_log file for the main domain reports:

Premature end of script headers: index.php
Premature end of script headers: cron.php

Our cron is running ever 5 minutes.


I went in and started checking all our sites that run in the multi-site, and indeed all of them are showing the error messages.

Yikes. I submitted a ticket to Support, i think all i can seriously do right now is wait… well that and start moving the site to another server.


I went into the db and removed the cron_semaphore from variable table, then removed the entry for variable from the cache table, and the site came back. Its still ungodly slow though.

While there are actually several things than can be the cause of this, by far the most common reason on a shared server is that your user’s php5.cgi processes are being killed by our procwatch daemon.

Procwatch is a daemon that runs constantly on shared servers to monitor the usage of RAM/CPU and execution time so that no single user can use an inappropriately high percentage of the shared resources and impact the overall health of the server or the server’s ability to serve all users’ pages.

When it finds a process that is using too great an amount of resources, iit kills that process. If it does this to a running script, the resultant error the server shows is “premature end of script headers” - the script can’t complete.

If you routinely find your error logs showing this error, generate a support request and ask that they check the procwatch logs for the user you site is running as/under (the user that CGI runs as, or the FTP user under which the site is run).

If, in fact, this is what is happening, there are only two ways to resolve this:

  1. Decrease the overall RAM, CPU, or execution time required for your scripts to process, create, and serve your site.

  2. Move the site to a VPS (DreamHost PS), or dedicated server, where you can reserve sufficient RAM for your own processes to use without impacting other users on the server.

The first approach can prove difficult depending upon your scripts, your content, and your expertise, but if you can do that your site can continue to run on a shared server without errors. The second alternative is simpler, but involves additional cost for the PS services, and sufficient RAM/CPU to avoid these errors.

Hopefully, this explanation will be helpful for some here.

–DreamHost Tech Support

This was very helpful in getting things sorted, but possibly not for the reasons given.

What it did do was to wake me up to look at things more closely rather than moan about things and feel an out of control victim. (DH support were impeccable incidentally - this is not a negative comment)

Support did give me the above information but php info script showed that I was using the DH php.ini -

I found that my .htaccess was missing as was the cgi wrapper for my php.ini - not sure how this happened, but it was unlikely to be anyone but me!

Once I’d set this right everything is back to normal (I have my memory limits set lower than the DH default). Unfortunately normal isn’t all that good, and not as good as I can get it in another environment.

So my apologies to anyone who may have been affected.

Meanwhile I am moving the site to a managed VPS back in the UK - cheaper and better service (than DH vps) without the GBLX router bottleneck that seems to kick in everyday. (Nothing DH can help with as it is someone else altogether)

So many thanks.

Ah! As I said, there can actually by many things that can cause a premature end of script error - and your situation with your .htaccess files/PHP config is one of them. I am glad your were able to get to the bottom of that in spite of my “in most instances” generalization of why this happens. :slight_smile:

I’m gald to hear that you had a good experience with the support staff, and I certainly understand about the decision to move the site. One size does not fit all, and no single host is best for everyone, or for every site.

I wish you all the best going forward with your site!

–DreamHost Tech Support

Support answer:

It looks like our admins noticed an issue turning up with the web server your sites are tied to. They are currently working to repair the problem and bring the service back up.

I apologize for the inconvenience =(

I already have two days with the problem and I lost my head trying to solve it (all possible solutions, .htaccesse, wordpress core files, rename theme folder, etc)

Now I just have to wait … and my business and my clients …