After developing a Rails app locally, the next step is to put it online. After developing a Rails app and previewing it locally on your computer, the next step is to put it online so others can see it. This is called deploying your app.

Heroku is a popular hosting service that is free to start using. Here’s how to deploy your Rails app to Heroku.


  1. Create a new Heroku account.
  2. Install the Heroku Toolbelt on your computer. The Heroku Toolbelt is installed by default in new Codecademy workspaces.
  3. In the terminal, log in using the email address and password you used when creating your Heroku account:

    $ heroku login
  4. In Gemfile, add the pg gem to your Rails project. Change:

    gem sqlite


    gem 'sqlite3', group: :development gem 'pg', '0.18.1', group: :production
  5. In Gemfile, add the rails_12factor gem::
    gem 'rails_12factor', group: :production
  6. In the terminal, install the gems specified in the Gemfile:
    $ bundle install
  7. Ensure config/database.yml is using the postgresql adapter. Change:

    production: <<: *default database: db/production.sqlite3


    production: <<: *default adapter: postgresql database: db/production.sqlite3
  8. Commit your changes to git:
    $ git add . $ git commit -m "Heroku config"
  9. In the terminal, create an app on Heroku:
    $ heroku create
  10. Push your code to Heroku:
    $ git push heroku master
  11. If you are using the database in your application, migrate the database by running:
    $ heroku run rake db:migrate
  12. If you need to seed your database with data, run:
    $ heroku run rake db:seed
  13. Get the URL of your app and visit it in the browser:
    $ heroku apps:info
    In the output, copy the address in the Web URL field. Open a new tab in your browser, and visit your app.

Check out Heroku’s Rails docs for more information.