Report this

What is the reason for this report?

secret_key_base missing and nginx restart fails

Posted on June 13, 2015

I followed this guide: https://gorails.com/deploy/ubuntu/14.04 to set up my application.

Now I have a few errors:

1)When I do service nginx restart, it fails. When I do sudo nginx -t it says everything is fine.

2)When I go to my website, I get Incomplete response received from application.

When I looked into the logs, it says that secret_key_base is missing. However, I have hard coded in shared/config/secrets.yml the secret key so I’m not sure what is going on.

Thanks



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The first step to debugging the Nginx issue is to check the error logs. You can see the most recent entries with:

  1. tail /var/log/nginx/error.log

By default, Rails project will hard code the secret_key_base for the test and development environments in config/secrets.yml The value for production is stored as the SECRET_KEY_BASE environmental variable:

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Have you hardcoded it for production as well? The first thing I’d double check is what environment the application is starting in. If you are using Unicorn as your application server with an init script to start and stop it, a common practice is to set the RAILS_ENV in /etc/default/unicorn which the init script sources.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.