Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I often get a "premature end of script headers" error in my apache log which results to an internal 500 error. I understand what the error message means - that my application did not give the browser the headers it needs (and maybe nothing at all), but the odd thing is that this does not happen all the time. It actually usually happens the first few times I go to my website after a deploy. Could this be a memory issue? Does anyone know how to trouble shoot this? My apache log isn't really telling me anything.

I am running a ruby site using the rails framework on ubuntu hardy.

thank you!

share|improve this question

2 Answers 2

If this is happening right after a deploy, what it probably means is that the Ruby process is restarting and isn't ready to serve pages yet. Apache will only give it a certain amount of time to serve each page, and then it will time it out and serve a 500. Once the Ruby process 'warms up' then everything is fine again.

Your Apache access logs should tell you how long the failed requests took. My guess is that they will be the same as an Apache-configured timeout; for example: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidconnecttimeout

share|improve this answer

What script are you running, Perl?

You can try enabling warnings and using Carp to trap the errors like this:

#!/usr/bin/perl -w
use strict;
use CGI::Carp qw/fatalsToBrowser/;
share|improve this answer
    
actually ruby, i updated the question –  Tony Nov 12 '09 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.