Rails App Error: Premature end of script headers
Asked Answered
L

4

7

My setup: Ubuntu 12.04 LTS, Apache, Phusion Passenger, latest Ruby and Rails.

When I visit my website, I get a 500 Internal Server Error. Error Logfiles: Premature end of script headers

Does somebody know how to solve that problem?

Lyonnesse answered 19/1, 2013 at 22:4 Comment(2)
Premature end of script headers this is in your apache logs, and is pretty useless on it's own. Do your rails logs give you any better information?Pearlypearman
in production.log there is nothing special in my opinion. The last line is: Connecting to database specified by database.yml. I don't use a db yet and there is no db installed on the server. But i specified a postgresdb in database.yml . Could this cause that error?Lyonnesse
P
4

If you have a database configured for production in your config/database.yml that doesn't exist on the server as you mentioned in the comments, that could be the source of your issue since it's failing to establish a database connection.

Remove that connection from your config/database.yml and restart your app.

Pearlypearman answered 19/1, 2013 at 22:28 Comment(0)
F
8

Just posting here in case other people have the same problem as I did.

I followed the Rails tutorial and part of that tutorial was making sure the secret_token was generated dynamically (listing 3.2 in the link) as a .secret file in the application root.

The problem was that the application somehow didn't write a token to the file, so I took the value from my development .secret, modified it, and saved it on the server. That made my application work in production.

Flyback answered 30/3, 2014 at 13:58 Comment(0)
P
4

If you have a database configured for production in your config/database.yml that doesn't exist on the server as you mentioned in the comments, that could be the source of your issue since it's failing to establish a database connection.

Remove that connection from your config/database.yml and restart your app.

Pearlypearman answered 19/1, 2013 at 22:28 Comment(0)
A
0

Ok. I encountered exactly the same problem using dreamhost VPS.

I was doing 2 mistakes. Firstly i didnt run "bundle exec rake db:migrate" in production mode, i.e "bundle exec rake db:migrate RAILS_ENV=production"

but this problem still kept showing up. Then i tried Jesper8 answer. I ran "rake secret" and copied the secret token to config/secrets.yml file infront of "production: secret_key_base: "

Restarted my app and it worked

Hope this might help someone facing similar problem

Argos answered 3/4, 2016 at 12:22 Comment(0)
C
-1

Make sure you environment is development:

RailsEnv development

Add to Virtualhost config

Calcific answered 18/9, 2014 at 11:1 Comment(1)
It may be a useful debugging step but this reads like a production server, and using a development rails environment in production is Not GreatBulbil

© 2022 - 2024 — McMap. All rights reserved.