Rails, Missing `secret_key_base` for 'production' on Ubuntu with unicorn and nginx

327 views Asked by At

I'm trying to run my rails app on Ubuntu for the first time using nginx and unicorn. My question is, when I look at my log, I see the following error.

`app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (
RuntimeError)`

I looked at my secrets.yml which looks like,

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

...

When I type echo $SECRET_KEY_BASE on my command line to check to make sure that the key is set, I get a secret key, which seems to indicate that the key is correctly set. What is missing here?

1

There are 1 answers

0
Shun John Iwase On

Your unicorn process runs as root. however you probably set your key with non-root user.
To fix this problem, I recommend you to use dotenv(https://github.com/bkeepers/dotenv).