500 Error in Rails Using Apache and mod_rails Passenger

So I just spent the good part of 4 hours trying to figure out why my fresh Ruby on Rails 2.1 apps was giving me a 500 error on my slice with mod_rails.

Permissions? No. Configurations? No. Etc etc.

I’ll just get straight to the point: apparently it was my database. Sure I ran:

rake db:migrate

..and it migrated fine, but yet still a 500 error like I tested many times. The fix?

rake db:migrate RAILS_ENV=”production”

Seems rake was stuck in the development environment. I’m not above saying it was just my ignorance of mod_rails environments, but why on earth would passenger default to development when it’s clearly made for production?

3 Responses to “500 Error in Rails Using Apache and mod_rails Passenger”

  1. Hongli Lai Says:

    ‘rake’ has got nothing to do with Phusion Passenger. It’s a separate tool. Just like all Rails commandline tools, it respects the RAILS_ENV environment variable as the authoritative way to define the environment in which it operates. Phusion Passenger itself defaults to production environment.

  2. andrew Says:

    Hongli, thanks for the clarification on Passenger’s default. I am aware rake has nothing to do with it, and assumed rake used the detected current ENV (somehow). Maybe it just wasn’t detecting it for some reason?

    Honestly it’s been a good year since using Rails in production, in a completely different hosting setup, and I don’t think I had to worry about it. But glad to know my (original) assumptions were correct, before my troubles.

    Since then it appears to be running great - so awesome!

  3. enzor Says:

    One thousand thanks for this tip
    really, i lost 2 days of work trying to sneak out of this problem.
    now al go smoothly ;)

Leave a Reply