Masatoshi Nishiguchi

Heroku troubleshooting

Everytime I get an error from Heroku, it is typically time-consuming to troubleshoot without any resources at hand. So I decide to write up my past Heroku troubleshooting experiences for my future self.

Before starting

Diagnosing errors at Heroku

Some possible causes

Troubleshooting I did in the past

Error: Some gems seem to be missing from your vendor/cache directory

$ git rm -rf vendor/cache
$ git add ...
$ git commit ...
$ git push heroku master

Error: failed to push some refs to ‘https://git.heroku.com/my-app.git’

Read the error message throughly. Often there is a clue in messages.

Missing files

Missing gems

$ git rm Gemfile.lock
$ bundle install
$ git add ...
$ git commit ...
$ git push heroku master

Error: Heroku deployment error H10 (App crashed)

Check if the production database is up-to-date

$ git push heroku master     # Push up to Heroku repo
$ heroku pg:reset DATABASE   # reset the production database

Missing CSS on Heroku Deployment

Check if the current Heroku app name is registered

$ git remote -v
$ git remote rm heroku
$ git remote add heroku git@heroku.com:APP_NAME.git

js files not loading in production but working well locally

# Precompile the assets for production
$ RAILS_ENV=production bundle exec rake assets:precompile
# Note: If Devise.secret_key is not set, add one to your Devise initializer

Check Heroku-supported Ruby/Rails versions

An error occurred while installing Ruby ruby-x.y.z

Check if Sendgrid is configured (if applicable)

$ heroku addons:add sendgrid:starter
$ heroku config:get SENDGRID_USERNAME
$ heroku config:get SENDGRID_PASSWORD

Check if CarrierWave & S3 are configured (if applicable)

$ heroku config:set S3_ACCESS_KEY=<access key>
$ heroku config:set S3_SECRET_KEY=<secret key>
$ heroku config:set S3_BUCKET=<bucket name>

Destroy the Heroku app and re-create it

$ heroku apps:destroy --app my-app
$ heroku create my-app
$ git push heroku -u master

Claer the asset pipeline cache

$ rake tmp:cache:clear

Reference