visit
To do this, you have to sign-up for Heroku at
Disclaimer:Here we assuming you run Ruby 2.6.5 and Rails 5.2.4.3 running on Ubuntu 20.04
To install the correct version for your system follow instructions at
So you have to
gem install pg
in your system, then change gem sqlite3
to gem pg
into your Gemfile
run bundle install
in your terminal, ensure that your config/database.yml
file is using the postgresql adapter like this :default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development: <<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: <<: *default
database: db/test.sqlite3
production: <<: *default
database: db/production.sqlite3
git add
,git commit
, and git push
your code onto the master branch. Now that everything is setup correctly, fresh&clean and your DB adapter is fine it's time to call the Heroku CLI.Make sure you are in the directory that contains your Rails app, then create an app on Heroku:
$ heroku create -
this will set your remote branch for deployment. You can check with:$ git config --list | grep heroku
Deploy your code:
$ git push heroku master
This will fetch, install and set gem, compile your code, run bundle and all the tasks needed for your app to stay live on the web.If you are using the database in your application, you need to manually migrate the database by running:
$ heroku run rake db:migrate
Now your app is on the Heroku server but to be able to visit and use this app you have to enable at least a on your app.
To be sure, run:
$ heroku ps:scale web=1
Your Web app is now online up and running, you can check by running:
$ heroku open
You can also check in the browser with the URL provided by Heroku.If you want to change the URL of your app you can go to your dashboard and change the URL to whatever you like, but remember to change also remote as Heroku suggests:$ git remote rm heroku
$ heroku git:remote -a newname
It is better to change directly from your app Git repository with:$ heroku apps:rename newname
new name
is the name you want to give to your URL application.Hope this will be helpful for your first but not last deploy.Have a nice day and happy coding to everyone.