Background

When you deploy your app to Heroku, Heroku gives you a default herokuapp.com URL (e.g., https://cryptic-eyrie-5775.herokuapp.com/). When you are ready to use Heroku for live traffic, you can add your own custom domain (e.g. http://www.yourname.com).

Instructions

  1. Buy a domain name. A popular domain registration service is Google Domains. Search for a domain name (e.g. yourname.com) and purchase it.
  2. In your project, from the terminal tell Heroku which domain you want to map to your application.

    $ heroku domains:add www.yourname.com
  3. Go to your Google Domains account. In the left menu click My domains.

  4. Go to your domain name and click the DNS icon DNS.
  5. Scroll down to the Custom resource records section, and add a CNAME record pointing the www subdomain to your Rails app's herokuapp.com hostname.

    DNS

    This change will take 1-2 minutes to take effect.

  6. Check that your DNS is correctly configured:

    $ host wwww.yourname.com
  7. Visit www.yourname.com to see if it works.

Check out Heroku's custom domains docs for more information.