# Premature end of script headers: dispatch.cgi

**URL:** <https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463>\
**Category:** Deployment\
**Created:** [May 6, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463 "2007-05-06T13:56:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [May 6, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/1 "2007-05-06T13:56:52Z")

</div>

Hi!

I’m trying to setup rails in my remote server: fedora-core-4-x86\_64  
running on vps.

Apache is already installed… and i installed ruby / gems / rails  
manually via ssh. when i’m creating a rails app and placing a sym link  
in httpdocs to its public directory… the “welcome aboard” page is  
running (simple html) but none of my controllers is working…

I verified rights for directories / files but i’m always recieving :

Application error  
Rails application failed to start properly

And in the server log files , i have: “Premature end of script headers:  
dispatch.cg”

Many people in the recommend the fcgi and mod\_fcgi… but i want get  
applicatuion running with cgi first!

Thanks in advance

---

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [May 7, 2007, 4:59pm UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/2 "2007-05-07T16:59:14Z")

</div>

Maybe this is a very wide question…

Is there any config to do in the apache files to tell him that we are  
running on rails ? or does the rails install made sth that i can check?

---

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [May 8, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/3 "2007-05-08T18:01:43Z")

</div>

The first thing that comes to my mind if i see this error is problem  
with your ruby path in the dispatch.cgi file.You can go a head with  
dispatch.fcgi. It worked for me…its cool…

---

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [May 9, 2007, 12:42pm UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/4 "2007-05-09T12:42:42Z")

</div>

Syed Arif wrote:

> The first thing that comes to my mind if i see this error is problem  
> with your ruby path in the dispatch.cgi file.You can go a head with  
> dispatch.fcgi. It worked for me…its cool…

I’m choosing cgi just because i’m still in development/test stage… and  
the ruby path is unfortunately correct!

---

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [January 25, 2009, 12:34am UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/5 "2009-01-25T00:34:27Z")

</div>

Syed Arif wrote:

> RailsRoller wrote:
> 
> > Syed Arif wrote:
> > 
> > > The first thing that comes to my mind if i see this error is problem  
> > > with your ruby path in the dispatch.cgi file.You can go a head with  
> > > dispatch.fcgi. It worked for me…its cool…
> > 
> > I’m choosing cgi just because i’m still in development/test stage… and  
> > the ruby path is unfortunately correct!
> 
> As far as i am concerned, the error is due to some setup problem only,  
> nothing to do with ur rails application. I suggest u to move forward  
> with the fcgi, cause that is the standard way if you are deploying in  
> apache.

the reason you are getting this error is because dispath.cgi is not  
generating proper HTTP headers because of an error. To find out what is  
going on change your current directory to the public\_html/appdir/public  
then type:

./dispatch.cgi

and you should find out what the problem is.

---

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [May 14, 2007, 7:59am UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/6 "2007-05-14T07:59:01Z")

</div>

RailsRoller wrote:

> Syed Arif wrote:
> 
> > The first thing that comes to my mind if i see this error is problem  
> > with your ruby path in the dispatch.cgi file.You can go a head with  
> > dispatch.fcgi. It worked for me…its cool…
> 
> I’m choosing cgi just because i’m still in development/test stage… and  
> the ruby path is unfortunately correct!

As far as i am concerned, the error is due to some setup problem only,  
nothing to do with ur rails application. I suggest u to move forward  
with the fcgi, cause that is the standard way if you are deploying in  
apache.

---

<div class="post-metadata">

**Author:** ![RailsRoller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@RailsRoller](https://www.ruby-forum.com/u/RailsRoller)\
**Post date:** [January 25, 2009, 12:35am UTC](https://www.ruby-forum.com/t/premature-end-of-script-headers-dispatch-cgi/103463/7 "2009-01-25T00:35:25Z")

</div>

Mario J. wrote:

> going on change your current directory to the public\_html/appdir/public

Of course, appdir above is the directory for your rails application.
