Rails app won't run on Dreamhost - "incomplet headers" error


#1

Can anyone provide some expert debugging help here? What’s the first
step to take to see what the issue is here?

I have no errors in the rails app’s log files. The only errors I have
are those provided by apache and they are:

‘FastCGI: Incomplete headers (0) bytes received from server’

I’ve tried editing the shebang line, removing line feeds, but nothing
seems to work.

Thanks for any ideas.

rich


#2

When this happened to me, I found that I had some leftover puts
statements that I had used when debugging with webrick locally.

Maybe you also have some puts statements in your code somewhere?

Just a shot in the dark…

Jeff
www.softiesonrails.com

Rich B. wrote:

Can anyone provide some expert debugging help here? What’s the first
step to take to see what the issue is here?

I have no errors in the rails app’s log files. The only errors I have
are those provided by apache and they are:

‘FastCGI: Incomplete headers (0) bytes received from server’

I’ve tried editing the shebang line, removing line feeds, but nothing
seems to work.

Thanks for any ideas.

rich


#3

either your dispatch.cgi or dispatch.fcgi (depends on your setup in
.htaccess) is referencing an invalid ruby location.

check the shebang (#!/usr/bin/ruby) declaration of the dispatch file and
verify that it’s referring to the correct ruby location.

hope this works for you,
andy


#4

oops, looks like this has been tried? ( I should have read the entire
email)

I haven’t run across that error without the shebang line correction
being
the fix. :frowning:


#5

Thanks, Jeff, but no puts for me :(. It’s frusterating - I’ve tried so
many things. It seems pretty common though, this error. dig your blog,
by the way, been reading it for a little while now. I share your
sentiments with regard to m$!

Jeff C. wrote:

When this happened to me, I found that I had some leftover puts
statements that I had used when debugging with webrick locally.

Maybe you also have some puts statements in your code somewhere?

Just a shot in the dark…

Jeff
www.softiesonrails.com


#6

Rich,

What happens if you just create a new rails app from scratch? Can you
at least get the “Congratulations…” page to appear?

I guess maybe some more background might help… has your site ever
worked before on DreamHost? Do you get this error only when calling a
certain action? Oh, and did you select FastCGI when setting up the
virtual root in the DreamHost control panel?

Sorry for the seeminly dumb questions… just trying to think of all the
stuff I had to look at when I had this problem before.

Jeff


#7

Andrew S. wrote:

either your dispatch.cgi or dispatch.fcgi (depends on your setup in
.htaccess) is referencing an invalid ruby location.

thats what i was hoping for. I’ve tried:

#!/usr/bin/env ruby
#!/usr/bin/ruby
#!/usr/bin/ruby1.8

none seem to work :frowning:

check the shebang (#!/usr/bin/ruby) declaration of the dispatch file and
verify that it’s referring to the correct ruby location.

hope this works for you,
andy


#8

Hi Rich,

Did you have your app running at Dreamhost at one point and it
failed, or has it not ever been running?

On Dreamhost I had to change the Ruby path in dispatch.fcgi and
dispatch.rb to:
#!/usr/bin/ruby1.8

Don’t forget to:
chmod -R 775 public
chmod -R 775 log

And to cycle an update to the app:
killall -USR1 dispatch.fcgi

And (in the normal case) your app directory has to be given the full
domain name that you set up, e.g. myRailsApp.myDomain.com, and it
must be set to the path myRailsApp.myDomain.com/public

I suspect the shebang line might do the trick though.

FYI-- just found out that Dreamhost already has ImageMagic installed
so you just need to put the RMagic gem in your vendor/plugins
directory and you’ve got RMagic available. Cool! …especially when
used with the filecolumn plugin.

Cheers,
russ


#9

hi russ, I’ve tries all your ideas, still no go. Oddly, to answer your
first question, it did work at one point. A few requests ran
successfully and then I needed to update a few things and reload the
app. THis is where I get fuzzy… I can’t remember doing anything other
than tring to hard code the RAILS[ENV] into environment.rb THis was
before understanding how to best reload an app on a shared host. But
that files been replace by the origianl so I can’t imagine that having
any effect.

When i try to run ruby dispatch.fcgi, I get a 500 error at the command
line.

Russ McBride wrote:

Hi Rich,

Did you have your app running at Dreamhost at one point and it
failed, or has it not ever been running?

On Dreamhost I had to change the Ruby path in dispatch.fcgi and
dispatch.rb to:
#!/usr/bin/ruby1.8

Don’t forget to:
chmod -R 775 public
chmod -R 775 log

And to cycle an update to the app:
killall -USR1 dispatch.fcgi

And (in the normal case) your app directory has to be given the full
domain name that you set up, e.g. myRailsApp.myDomain.com, and it
must be set to the path myRailsApp.myDomain.com/public

I suspect the shebang line might do the trick though.

FYI-- just found out that Dreamhost already has ImageMagic installed
so you just need to put the RMagic gem in your vendor/plugins
directory and you’ve got RMagic available. Cool! …especially when
used with the filecolumn plugin.

Cheers,
russ


#10

What happens if you just create a new rails app from scratch? Can you
at least get the “Congratulations…” page to appear?

yup

I guess maybe some more background might help… has your site ever
worked before on DreamHost?

i have, see the replyto russ

Do you get this error only when calling a

certain action?

it seems to be all requests. can’t pull up anything.

Oh, and did you select FastCGI when setting up the

virtual root in the DreamHost control panel?

yes

Sorry for the seeminly dumb questions… just trying to think of all the
stuff I had to look at when I had this problem before.

no problem, i apreciate the extra eyes!


#11

rich escribió:

hi russ, I’ve tries all your ideas, still no go. Oddly, to answer your
first question, it did work at one point. A few requests ran
successfully and then I needed to update a few things and reload the
app. THis is where I get fuzzy… I can’t remember doing anything other
than tring to hard code the RAILS[ENV] into environment.rb THis was
before understanding how to best reload an app on a shared host. But
that files been replace by the origianl so I can’t imagine that having
any effect.

I experimented similar errors. If you work on Windows perhaps executing

dos2unix dispatch.*

fixes the problem, cleaning the characters that Windows uses for
carriage returns . It worked for me.


Vicente Gallur V.
http://www.vgcomunicacion.com


#12

I’ve finally got it running. I cahnged two things. the first was to
uncomment the line:

ENV[‘RAILS_ENV’] ||= ‘production’

in environment.rb

and the second was changing (per Dreamhost’s wiki) the default code in
dispatch.fcgi to:

class MyRailsFCGIHandler < RailsFCGIHandler
SIGNALS = {
‘TERM’ => :exit_now,
}

def exit_now_handler(signal)
dispatcher_log :info, “ignoring request to terminate immediately”
end
end

MyRailsFCGIHandler.process! nil, 50

I’m not sure which is responsible for fixing the problem, but it’s one
of the two…

On 1/26/06, Vicente Gallur V. removed_email_address@domain.invalid wrote:

I experimented similar errors. If you work on Windows perhaps executing


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


http://brantinteractive.com
removed_email_address@domain.invalid
4034 skippack pike
v. 267.640.2195
f. 215.689.1454


#13

Rich B. wrote:

I’ve finally got it running. I cahnged two things. the first was to
uncomment the line:

ENV[‘RAILS_ENV’] ||= ‘production’

in environment.rb

I suspect that was the problem all along. Perhaps with this line
commented out, it was looking at the development environment instead?

If you’re feeling adventurous, could you undo the other change you made
to dispatch.fcgi and report back? (If you’d rather not it would be
understandable).

Thanks
Jeff
www.softiesonrails.com


#14

Where is environment.rb? I checked in config/environment.rb and there
was no such line that was commented out. The only thing that looks
similar is:

environment.rb is in the /config directory. but your line is correct
below

RAILS_ENV = ENV[‘RAILS_ENV’] || ‘development’

It says to “put it in your webserver’s configuration as the RAILS_ENV
environment variable instead” but I’m not sure what it means. I’ve
changed dispatch.fgci already and I’m still getting a “application
failed to start properly” error and my Apache logs are similar.

and if you request it from the command line, what do you see?


#15

Rich B. wrote:

I’ve finally got it running. I cahnged two things. the first was to
uncomment the line:

ENV[‘RAILS_ENV’] ||= ‘production’

in environment.rb

Hi, I have a similar problem.

Where is environment.rb? I checked in config/environment.rb and there
was no such line that was commented out. The only thing that looks
similar is:

RAILS_ENV = ENV[‘RAILS_ENV’] || ‘development’

It says to “put it in your webserver’s configuration as the RAILS_ENV
environment variable instead” but I’m not sure what it means. I’ve
changed dispatch.fgci already and I’m still getting a “application
failed to start properly” error and my Apache logs are similar.


#16

This might be obvious, but by default Dreamhost users only get ftp
access - not ssh. You need to specifically enable each user to access
via ssh in the Control Panel. If this isn’t enabled, you’ll get the
behaviour you’re describing from Putty.

I use Putty myself on Dreamhost and it’s very reliable.

Regards

Dave M.


#17

Rich B. wrote:

and if you request it from the command line, what do you see?

Well, this brings up another problem. Maybe I don’t have it turned on or
something, but I can’t log in via SSH. Putty just automatically closes
afer I login.
That is a problem, another problem is that I don’t have my DB set up
with the proper tables yet, but if that happens, shouldn’t I get a
DB-specific rails error, instead of an “application failed?”
I have also heard that syntax errors could cause Rails to not start.
Anyway to check these errors? They work fine locally.


#18

Rich B. wrote:

DB-specific rails error, instead of an “application failed?”

ruby dispatch.fcgi from the command line :slight_smile:

Check the shebang line in the dispatch.fcgi file. If you are using the
default that ships then it is
setup for something crazy like /usr/local/bin/ruby … which I think is
a OSX default. Crazy mac people.

Zach


#19

Well, this brings up another problem. Maybe I don’t have it turned on or
something, but I can’t log in via SSH. Putty just automatically closes
afer I login.

I second what david said.

That is a problem, another problem is that I don’t have my DB set up
with the proper tables yet, but if that happens, shouldn’t I get a
DB-specific rails error, instead of an “application failed?”

perhaps, but if you can’t successfully request dispatch.fcgi, then the
app will never load in the first place to make an entry to the log.

I have also heard that syntax errors could cause Rails to not start.
Anyway to check these errors? They work fine locally.

ruby dispatch.fcgi from the command line :slight_smile:


#20

Oh, and don’t forget to check that your public/.htaccess file refers
dispatch.fcgi and NOT dispatch.cgi.

Check the shebang line in the dispatch.fcgi file. If you are using the default that ships then it is
setup for something crazy like /usr/local/bin/ruby … which I think is a OSX default. Crazy mac people.