Rails App Error: Premature end of script headers

感情迁移 提交于 2019-12-08 17:40:13

问题


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?


回答1:


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.




回答2:


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.




回答3:


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




回答4:


Make sure you environment is development:

RailsEnv development

Add to Virtualhost config



来源:https://stackoverflow.com/questions/14419354/rails-app-error-premature-end-of-script-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!