Apache Error: Premature End of Script Headers

Share this article

‘Premature end of script headers’ Apache Error is like a big pain and will leave you with high stress on your head. There are several reasons which may trigger this error.

Here are a few helpful tips for you to fix this one. Usually, when executing the scripts we may come across the following error:

Premature end of script headers: /home/directory/public_html/index.php

A Server expects a complete set of HTTP headers, however when it does not get a complete HTTP header, this kind of errors may trigger. Let us take a close look at what all things can fire this error and find ways to deal with it.


Script’s permissions may trigger this error. CGI scripts can access only those resources that are enabled for user and group specified in httpd.conf.

If you’re facing such due to this one, you got to be really careful about your site and protect it from any further hacks since this usually happens if an unauthorized user is attempting to access scripts.

Residual Options

PHP may leave residual options in httpd.conf while upgrading and or downgrading which may lead to this error.

Use php –v on the command line to check the PHP version and carefully check whether any other version is mentioned in the httpd.comf. Comment any such lines where additional version information is mentioned, distill the httpd.conf and restart your Apache.


suEXEC, mod_perl or any third party module if configured incorrectly, interferes with the scripts in execution that will trigger this error.

Investigate your apache error_logs to find more specific information about this.

Resource Limit

If a script was killed due to the resource limit, this error may trigger. RLimitCPU & RLimitMEM directives in httpd.conf plays a key role for here. Hence investigate these areas closely if you’re facing the error due to the resource limit.

Large SUPHPs Log

This error may trigger when the SUPHP log goes up to 2 GB or large in size. Carefully study the SUPHP logs located at /usr/local/apache/logs/suphp_log and Gzip it and or simply null them.

Restart Apache and start fixing issues that you’ve identified in SUPHP logs.