2

I get this error, when running "heroku open"

"Internal Server Error

You must set config.secret_key_base in your app's config."

I've tried everything in this thread:

Heroku Config Secret Key Base Error

  • Set MyApp::Application.config.secret_token = ENV['SECRET_TOKEN'] in config/initializers/secret_token.rb
  • Created a .env file with the contents SECRET_TOKEN=NKUd7gisd7fueAISDfg....
  • Updated my .gitignore file to look like below

What else I have tried:

  • I added: DemoApp::Application.config.secret_key_base = ENV['SECRET_TOKEN'] to secret_token.rb file

  • Used figaro to create a application.yml file and pasted SECRET_TOKEN: 9489b3eee4eccf317ed77407553e8adc97baca7c74dc7ee33cd93e4c8b69477eea66eaedeb18af0be2679887c7c69c0a28c0fded0a71ea472a8c4abf3f0a19cb with my own SECRET_TOKEN

  • ran rake figaro:heroku

I still get the internal server error. Apologies if this is a total nub question, but this is my first try with the "heroku open" command.

Thanks, David

Community
  • 1
  • 1
dstung
  • 97
  • 2
  • 11

2 Answers2

2

Ok from heroku staff help turns out that my config/initializers folder was not pushing up to git.

Then these two posts solved it:

Config/initializers not pushing to repo

No submodule mapping found in .gitmodules for path

Best of luck

Community
  • 1
  • 1
dstung
  • 97
  • 2
  • 11
0

To set environment variables on Heroku, you need to use the Heroku Toolbelt from on local machine:

heroku config:set SECRET_TOKEN=f489b3eee4eccf317ed77407553e8adc97baca7c74dc7ee33cd93e4c8b69477eea66eaedeb18af0be2679887c7c69c0a28c0fded0a71ea472a8c4abf3f0a19ca

(Obviously, replace the token above with your own)

Then just make sure that you have MyApp::Application.config.secret_token = ENV['SECRET_TOKEN'] in your config/initializers/secret_token.rb file.

See Setting up config vars for a deployed application for further info.

Also make sure that you've added a secret_key_base entry for the production environment in your config/secrets.yml file:

production:
  secret_key_base: 527dacc0390e10df59278f1a18aa8ad14e429fa6ce522e5fb3b7ac358007dff4

Don't use the key posted here. You can generate a new one with a rake task and paste it into your config/secrets.yml file

bundle exec rake secrets
infused
  • 24,000
  • 13
  • 68
  • 78
  • Hi Infused, have toolbelt installed. I've also done the heroku config:set SECRET_TOKEN command. The line in my config/initializers/secret_token.rb is SampleApp::Application.config.secret_key_base = ENV['SECRET_TOKEN']. – dstung Aug 11 '14 at 23:47
  • Using "heroku config" my SECRET_TOKEN is displayed. But "heroku open" still doesn't work, any other ideas? – dstung Aug 11 '14 at 23:49
  • @user3911994, I've update my answer with some additional info on how to update your `config/secrets.yml` file with with a `secret_key_base` for production. – infused Aug 11 '14 at 23:51
  • Okay, I created a config/secrets.yml file and added the line you have production: secret_key_base: my key. Then pushed everything up to heroku. I still get the error. Do I need to do something else? – dstung Aug 12 '14 at 00:14
  • Are you able to start up the app locally in the production environment? `bundle exec rails s -e production` You will need to create a production database and update your database.yml to test this, but its much easier to test it locally then to test it on Heroku. – infused Aug 12 '14 at 00:21
  • When I run "rails s" to test locally everything works great. I'm just following Hartl's tutorial for Ruby on Rails and he uses the "heroku open" command at the end of Ch 5. – dstung Aug 12 '14 at 00:24
  • The command you gave me "bundle exec rails s -e" works but it looks like it takes me back to Ch 3?? None of my bootstrap CSS is included. – dstung Aug 12 '14 at 00:25