Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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:

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


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.