DEV Community

Jasterix
Jasterix

Posted on • Edited on

3 Heroku errors and how to bypass them

Yesterday, I deployed my Chingu solo project Heroku. After 10 hours of debugging, I finally got the working project I needed to meet the requirements, but wow– what a painful experience!

It seemed that I got every possible between the initial project creation and actually getting my rails API deployed.

The project

  • Rails API to generate a GIF for every HTTP status code
  • Vanilla JS frontend | Rails backend

The context

I worked on this project before so I wasn't worried about making the API. But I knew I would have to:

  • convert my SQLite database to Postgres
  • host the front and back ends separately

The challenges (aka the errors)

Error 1

  • FATAL: permission denied for database "postgres"
Running rake db:setup on ⬢ statuslive... up, run.3270 (Free)
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Couldn't create 'dfkftiogchg03i' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Enter fullscreen mode Exit fullscreen mode
  • I made the mistake of specifying the database variables in my database.yml. But those will be generated by Heroku:
production:
  <<: *default
  adapter: postgresql
  database: statusbackend_production
  username: 
  password:  <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
Enter fullscreen mode Exit fullscreen mode
  • After updating my database file, I also made sure to
  • delete my database on Heroku
  • delete my schema
  • recreate my database
    • heroku addons:create heroku-postgresql:hobby-dev
  • recreate my databese
    • heroku rake db:schema:load
  • run migrations
    • heroku run rake db:migrate

Error 2

  • My page crashed immediately after deployment. This on was challenging because the Heroku logs were less than helpful
2019-10-30T00:46:41.342662+00:00 heroku[run.4698]: Process exited with status 1
2019-10-30T00:46:41.383224+00:00 heroku[run.4698]: State changed from up to complete
2019-10-30T00:46:44.149803+00:00 heroku[router]: at=info method=GET path="/boards" host=statuslive.herokuapp.com request_id=5b00da13-1b4c-4bac-98d3-e305c5b4a758 fwd="98.225.252.60" dyno=web.1 connect=1ms service=82ms status=304 bytes=231 protocol=https
Enter fullscreen mode Exit fullscreen mode
  • I got this error a few different types but here are the things I tried to varying degrees of success
  • heroku restart
  • set config.active_storage.service to :local

I also recommend running heroku rake immediately after each deploy, because this will catch any syntax errors that cause your app to crash. This is the commend I started using to deploy

  • git push heroku master && heroku rake

Error 3

  • I got a few gem errors, but addressing 1 gem error would just lead to another one, starting
.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/spec_set.rb:87:in `block in materialize': Could not find nio4r-2.5.2 in any of the sources (Bundler::GemNotFound)
Enter fullscreen mode Exit fullscreen mode
  • I tried a few things to fix this error including
    • gem pristine nio4r --version 2.5.1
    • deleting my gemfile.lock
    • running bundle update
    • running bundle install
    • But the only thing that worked was gem pristine --all

During my debugging adventure, I read a lot of Stack Overflow questions and answers. This thread is one I read a few times, when I continued getting errors after my app was successfully deployed.

As I wrote this blog, I noticed that reviewing my terminal logs, it was difficult to keep track of what command made the difference. But next time I deploy a project to Heroku, I will try to take more detailed notes of what fixed which error

Top comments (2)

Collapse
 
felipsimoes profile image
Felipe Simoes

Thanks for that! I just stumbled on the same project after updating my application to rails 6. Despite changing the production parameters on database.yml I could not pass the migrate step.
It help me a lot!

Collapse
 
jasterix profile image
Jasterix

That's great to hear! Good luck with the project