# Dispatch.cgi error affecting specific browsers

**URL:** <https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752>\
**Category:** Rails\
**Created:** [February 15, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752 "2006-02-15T20:18:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [February 15, 2006, 8:18pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752/1 "2006-02-15T20:18:02Z")

</div>

I have a rails app that is accessed through Apache 2 (just using cgi  
now; will add fastcgi later when everything is working).

The app works fine with some os/browser combos at my work site:  
windows/IE  
Mac/safari  
Mac/firefox  
Linux/firefox

But it fails on windows/firefox and my colleague’s (at a different site)  
mac/safari (we are running the same os version and version of safari)

The actual error reported in the browser is:  
Application error  
Rails application failed to start properly

And in the apache error log:  
Premature end of script headers: dispatch.cgi

I have read numerous postings about this error and have made sure that:  
-permissions on my app are set correctly  
-hashbang line is correct in dispatch.cgi  
-line endings are correct in dispatch.cgi

What seems to be different than most other reports of this problem is  
the fact that it works on some browsers but not others. Any ideas?  
Thanks

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [February 15, 2006, 9:01pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752/2 "2006-02-15T21:01:04Z")

</div>

Hi Dan ~

What OS are you serving from? I had many issues with Windows hosting and  
Apache.

I would highly recommend the switch to FastCGI. I personally had  
numerous  
issues with Apache+FastCGI, and jumped ship for Light. Never been  
happier.

~ Ben

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [February 15, 2006, 9:05pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752/3 "2006-02-15T21:05:20Z")

</div>

Ben R. wrote:

> Hi Dan ~
> 
> What OS are you serving from? I had many issues with Windows hosting and  
> Apache.

Serving from Fedora Core 4 Linux.

> I would highly recommend the switch to FastCGI. I personally had  
> numerous  
> issues with Apache+FastCGI, and jumped ship for Light. Never been  
> happier.

I’ve had trouble getting lighttpd to work, also we have some limitations  
which may dicate using apache. I think fastcgi is a good idea, but I  
also think it’s a good idea to make sure everything works using cgi  
first. I may be wrong.

Still having the problem…hope this rings a bell with someone…

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [February 15, 2006, 10:27pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752/4 "2006-02-15T22:27:03Z")

</div>

Craig W. wrote:

> > Still having the problem…hope this rings a bell with someone…
> 
> * * *
> 
> try (for S & G)
> 
> service httpd stop
> 
> rm /tmp/ruby.sess\*  
> rm -fr /tmp/fcgi\*
> 
> service httpd start
> 
> (just to make sure that all session data has been cleared out before you  
> start httpd)
> 
> Craig

That worked!

Thanks. BTW, what do you mean by S & G?

Also, what are the best practices for removing the session files? The  
agile book suggests a cron script to remove all scripts over 6 hours  
old.

Is it a good idea to remove all session files when restarting the web  
server?

Do you know what the mechanics of this problem are? In other words, how  
exactly does a session file cause a “premature end of script headers”  
error? Just trying to understand and help prevent the problem in future.

Thanks again

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [February 15, 2006, 10:59pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752/5 "2006-02-15T22:59:21Z")

</div>

On Wed, 2006-02-15 at 22:27 +0100, Dan T. wrote:

> > service httpd start
> > 
> > (just to make sure that all session data has been cleared out before you  
> > start httpd)
> > 
> > Craig
> 
> That worked!
> 
> Thanks. BTW, what do you mean by S & G?

* * *

## sh\*ts and grins - obtuse expression that stuck with me after I first heard it

> Also, what are the best practices for removing the session files? The  
> agile book suggests a cron script to remove all scripts over 6 hours  
> old.

* * *

## makes sense but I took that out to 8 hours (just in case)

> Is it a good idea to remove all session files when restarting the web  
> server?

* * *

## I think experience is gonna teach me some of this…I have less than little

> Do you know what the mechanics of this problem are? In other words, how  
> exactly does a session file cause a “premature end of script headers”  
> error? Just trying to understand and help prevent the problem in future.

* * *

I doubt I can give you a very good explanation but by wag is simply that  
you have a browser open that is attached to a session and the server  
methodology has changed but the browser is still attached to the session  
and so it remains…by deleting the session, it makes the server create  
a new session with the new methodology/parameters.

Craig

---

<div class="post-metadata">

**Author:** ![dandante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9fc29f/32.png) [@dandante](https://www.ruby-forum.com/u/dandante)\
**Post date:** [February 15, 2006, 10:16pm UTC](https://www.ruby-forum.com/t/dispatch-cgi-error-affecting-specific-browsers/68752/6 "2006-02-15T22:16:41Z")

</div>

On Wed, 2006-02-15 at 21:05 +0100, Dan T. wrote:

> > numerous  
> > issues with Apache+FastCGI, and jumped ship for Light. Never been  
> > happier.
> 
> I’ve had trouble getting lighttpd to work, also we have some limitations  
> which may dicate using apache. I think fastcgi is a good idea, but I  
> also think it’s a good idea to make sure everything works using cgi  
> first. I may be wrong.
> 
> Still having the problem…hope this rings a bell with someone…

* * *

try (for S & G)

service httpd stop

rm /tmp/ruby.sess\*  
rm -fr /tmp/fcgi\*

service httpd start

(just to make sure that all session data has been cleared out before you  
start httpd)

Craig
