Missing `secret_key_base` for 'production' environment

1,040 views
Skip to first unread message

Reynier Pérez

unread,
May 6, 2014, 2:08:58 PM5/6/14
to rubyonra...@googlegroups.com
I've created a rails app (Rails 4.1.0) from scratch and I am getting a problem that I am not able to solve. I have installed and configured Apache Passenger Module, it works fine. Any time I try to access the virtual host I get an error 500:

    Missing secret_key_base for 'production' environment, set this value in config/secrets.yml

The secret.yml file contains the following configuration:

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

Even when it's not recommended I did this:

        production:
      secret_key_base: XXXXXXXXXXXXXXXXXXXXXXXXXXXX (random key)

But Apache logs show this:

    # tailf /etc/httpd/logs/error_log
    [Tue May 06 12:56:18 2014] [error] [client 192.168.3.1] Premature end of script headers:
    App 4405 stderr: [ 2014-05-06 12:56:18.5763 4421/0x9d48bdc(Worker 1) utils.rb:68 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 4421, thread 0x9d48bdc(Worker 1)):
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:440:in `validate_secret_key_config!'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:195:in `env_config'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:510:in `call'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/application.rb:144:in `call'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
    App 4405 stderr:        from /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'

How I can fix this error? How do I access the development enviroment? I mean how I can write code, test in my browser and then deploy to Heroku or just test in production enviroment?

Colin Law

unread,
May 7, 2014, 6:43:57 AM5/7/14
to rubyonra...@googlegroups.com
On 6 May 2014 19:08, Reynier Pérez <reyn...@gmail.com> wrote:
> I've created a rails app (Rails 4.1.0) from scratch and I am getting a
> problem that I am not able to solve. I have installed and configured Apache
> Passenger Module, it works fine. Any time I try to access the virtual host I
> get an error 500:
>
> Missing secret_key_base for 'production' environment, set this value in
> config/secrets.yml
>
> The secret.yml file contains the following configuration:

That should be secrets.yml (plural).

Colin
Reply all
Reply to author
Forward
0 new messages