secret_key_base missing and nginx restart fails

I followed this guide: 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.



Submit an 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:

  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.