cancel
Showing results for 
Search instead for 
Did you mean: 

Error: "Premature end of script headers"

UncleZen
Rising Star
Posts: 111
Thanks: 16
Fixes: 2
Registered: ‎15-08-2008

Error: "Premature end of script headers"

Im getting the following error:

Premature end of script headers

followed by Error 500
When running some, not all of my perl scripts
Googling found this:
http://httpd.apache.org/docs/1.3/misc/FAQ-F.html#premature-script-headers
But this will mean more to you than me.
EDIT: I see this has been raised before, but I dont have a .htacess file
http://community.plus.net/forum/index.php/topic,84357.0.html
3 REPLIES 3
maccladd
Newbie
Posts: 5
Registered: ‎15-03-2010

Re: Error: "Premature end of script headers"

My main site isn't working still, but I uploaded a test script just to get some confidence and that started off with getting the end of script error. A quick check of the permissions showed it was not executable, so I change the permissions to 700 (rwx------) and it then worked... just need to understand why my main app isn't showing any life....
UncleZen
Rising Star
Posts: 111
Thanks: 16
Fixes: 2
Registered: ‎15-08-2008

Re: Error: "Premature end of script headers"

This may help others.
I was getting this error and I was relying on $ENV{C_DOCUMENT_ROOT} to get the path to my scripts (perl).
As $ENV{C_DOCUMENT_ROOT} no longer existed, I amended the path manually so it was correct.
Now I dont get the "Premature end of script headers" error. I assume that because my path was wrong I was trying to access a script in an area of the webserver I was not allowed, hence the error.
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: Error: "Premature end of script headers"

Or you could add this near the top of your script:
($ENV{'C_DOCUMENT_ROOT'} = $ENV{'SCRIPT_FILENAME'}) =~ s/$ENV{'SCRIPT_URL'}/\//;

It'll be a bit more portable that way.