Ruby on Rails @ Dreamhost: Step By Step

software development


Is there a simple step by step explanation once you’ve successfully put Ruby on Rails? Rails seems to be working perfectly (creating frameworks when I generate controllers), but now I’m stuck between either getting the 500 error (“Application error Rails application failed to start properly”) when using dispatch.cgi or just having it hang with I change my .htaccess file to use dispatch.fcgi.

In each instance, here’s what I’m getting in my error logs:

— with .htaccess set to dispatch.cgi:

— with .htaccess set to dispatch.fcgi

[Tue Aug 9 19:22:11 2005] [error] [client] FastCGI: comm with (dynamic) server "/home/anzi/" aborted: (first read) idle timeout (240 sec) [Tue Aug 9 19:22:11 2005] [error] [client] FastCGI: incomplete headers (0 bytes) received from server "/home/anzi/"
It feels like I’m THAT close to getting this to work! This is really nerve-wracking …


You probably missed setting some permissions. Everything in public should be 755. You may also need to run dos2unix on the same files (from the shell). Check the wiki for more:

I also have some pointers:


-Tom Wilcoxen


Thank you so much - I thought only dispatch.fcgi needed to be chmoded - not everything in public. Everything is working really wonderfully now!

This is really quite revolutionary!


I’m still having problems.

i followed the instructions on exactly
(set fastcgi support, etc.,)
and I still get the Application error
"Rails application failed to start properly"

I chmoded 755 everything in the public directory. the public directory itself is chomded 755. So I don’t think it’s the permission issues.

I changed .htaccess to have the line
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

I even created a new rails directory, took their dispatch.fcgi file and copied it over to my directory (chmoded it 755 of course).

In my environment.rb I made sure that
RAILS_ENV = ENV[‘RAILS_ENV’] || 'production’
is my line.

the error log from apache is
FastCGI: incomplete headers (0 bytes) received from server

And I’m still getting that error message. Could there be anything missing that I didn’t do?

Note: When I change into development mode and have my .htaccess file to be
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

It works fine. But when I change it to fcgi (still in dev mode) it gives me that error.


For what it’s wearth I found this article:
It mentions a fix which we can’t make, but it seems to me dreamhost should look in to this.


In the last paragraph me mentions that it isn’t a recommended solution according to Tobias. Also, since there are Typo blogs running at DreamHost it can’t be necessary.

It is possible to get Typo running on DreamHost. I’d guess right now you need to run dos2unix on public/. I’ve run both that and set the permissions on lib/.rb too. I’d been editing fcgi_handler and was worried I had line ending problems with that file. It won’t hurt at any rate…


-Tom Wilcoxen


I have exactly the same problem as jchoe. I’ve seen other postings on the web that report the same problem. This one seems to go a little more in depth:

suggesting that we need the fcgi gem? He attributes the problem to dreamhost upgrading to rails 0.13.1 :




I’m having the same issue. Everything is peachy using the cgi method, but as soon as I edit my .htaccess to make use of fastcgi, the pages that were working before return an error.

Has anyone heard from Dreamhost on this one or found a solution?


I’m not sure what’s going on, but I have a couple of rails apps running at DreamHost without any IPN twiddling or fcgi gem presence, so I really don’t think those are your issues.

I really think 90% of the problems people have boil down to:

  • chmod 755 public/* (I’ve also done lib/* and config/*)
  • dos2unix the same files if you work on Windows
  • triple check your .htaccess file that .fcgi is selected
  • triple check that your sub domain has FastCGI enabled
  • make sure you set the path to ruby in the shebang:

#!/usr/bin/ruby/ – make sure that matches your server with which rubyTry running dispatch.fcgi from the command line:

./public/dispatch.fcgiYou should get something like a web response (possibly a 404). You may be a stack trace in which case you have an error in your application or environment (a file can’t be found would be likely).

It really probably isn’t something in the environment though, as there are applications running that don’t do anything special to work.

-Tom Wilcoxen
convergent arts
Signup with DreamHost Now Save $50! Promo code: CADHDISC


I too cannot get my Rails app (I’m trying to run Typo CMS) running properly with Apache.

  1. Everything has been chmoded correctly, even the lib/, config/ and I even did log/* for the heck of it.

  2. All my work has been done on while shelled in, not on a Windows.

  3. The fcgi module is absolutely selected and my domain undoubtedly has FastCGI enabled.

  4. [color=#CC6600]When I run dispatch.fcgi, I get nothing. It just sits there until I Ctrl C out of it.[/color]
    [EDIT: I wasn’t waiting long enough, I FCGI results in an application error and CGI results in a 404.]

  5. Correct me if I’m wrong, but isn’t the path to Ruby:

Note the lacking trailing slash, because ruby isn’t a directory.

My app runs fine (albeit very slow) on WEBrick, but all I get is a 500 on Apache.

[color=#CC0000]To add to this, if I set up Apache to run the plain CGI instead of FastCGI (via the .htaccess file), then my app runs fine. Once I add the “f”, the application fails.[/color]

If I run dispatch.cgi from the shell, I get a 404 as expected, but when I run dispatch.fcgi, I recieve an error page (only through the shell). This is the output of that error, in case somebody can make any sense of it:


That’s odd, I had no issues setting up rails to run fastcgi, or am I doing it correctly? The only thing I did was modify public/.htaccess and replace the rewrite rule for dispatch.cgi with the one for dispatch.fcgi. Order is important, this must be the last rewrite rule in the chain. I made some other related notes,


Yeah, shortly after I submitted that I got Ruby on Rails to work.

I ended up having to blow away my existing Rails app and start a new one from scratch, and I had to make sure it was running in Production mode.

Thankfully, it’s quite easy to set-up an app and get things running with Ruby on Rails, so it didn’t take too long.


I seem to have been having a similar problem to some other folks here. It was Ruby on Snails with just CGI, and 500 with FastCGI.

Well, I don’t know exactly what I changed, but suddenly it was working with the fcgi dispatch file and it was nice and snappy… and then… it was 500 again.

I switched it to CGI and then back to FastCGI, and it’s alive.

So, I’m not sure what’s happening here. (This is all in “development” mode… switching to “production” seems to cause 500s regardless of which CGI mode it is)


I just started a FastCGI page:

In particular, the fcgi_handler.rb has done wonders. Other than that, be sure to snuff any application errors. Those will end up damaging the dispatch.fcgi processes and result in the 500 errors. If you use the fcgi_handler linked above then you will avoid the 500 errors, but you’ll get a bunch of dispatch.fcgi processes hanging around. That shouldn’t be a major concern and as you get your app tightened up those should go down.

I have quite a few posts along those lines at my blog (above or in sig).


-Tom Wilcoxen
convergent arts