How to fix Incomplete response received from application from nginx / passenger in a rails application
I was trying to deploy a simple rails application( stack is Ruby 2.2.4, Rails 4.2.5, with passenger/Nginx as application/web server) to AWS EC2 and I was getting a weird error.
Incomplete response received from application
And looking at the Nginx/passenger logs I wasn't able to figure out the issue first hand. Then == I tried to debug in detail and changed the passenger_app_env
to development == so that I can see the debug logs in details and voila.!! I figured out how stupid I was.
Checking the logs, I see:
app error: Missing `secret_token` and `secret_key_base` for 'production' environment
== Yep, you got it right, I forgot to set the secret_token
in my env, and it caused the error. ==
After generating the secret_token
using
RAILS_ENV=production rake secret
and exporting it to the bash env using:
export SECRET_KEY_BASE=secret_token
and restarting Nginx using
touch tmp/restart.txt
I was able to bring my rails app online.
As they say:
Making mistakes simply mean you are learning faster. ~Weston H. Agor
Hope I save someone's time in future. :)