Adding a Custom Domain with Heroku and Google Domains

This is an update to the blog I wrote on March 31 2017. Every once in a while I deploy a web application to Heroku using Google Domains and I often end up spending a good amount of time looking up documentation on how to add a custom domain to Heroku. To save time for next time, I’ve compiled this blog for me and other Rails developers who might find themselves in a similar situation. This blog assumes you have a Ruby on Rails application already deployed to Heroku and a domain name hosted at Google Domains. If you need help deploying your app to Heroku, I would recommend the fantastic Ruby on Rails Tutorial by Michael Hartl. Otherwise, let’s get started.

  • Add your domain using the command below in your terminal
$ heroku domains:add
$ heroku domains:add
  • Retrieve your DNS Target which you’ll need for Google Domains by running the code below in your terminal.
$ heroku domains
  • You should see somethings like the code below.
=== your_heroku_appname Heroku Domain

=== your_heroku_appname Custom Domains
Domain Name DNS Target
────────────── ────────────────────────────
  • Next log into your Google Domains account
  • Click on Configure DNS
  • Find the Custom resource records section and do the following
  1. Type www in the first box
  2. Select CNAME from the dropdown menu
  3. Type in the @ into the last box that says Domain Name. and click on Add
  4. Next, in a new raw, type in @ in the first box that has an @ sign in it.
  5. Select A from the drop down.
  6. Type 1h in the box that says 1h
  7. Next we want to get the IP address of our domain name so lets do the following:
  8. Visit This Website
  9. Type your url into the IP-Address, Domain or URL: window
  10. Copy the IP address you receive
  11. Go back to your Google Domains Dashboard
  12. Paste the IP address into the last box that says IPv4 address in DNS configure, under the Custom resource records in your google domains dashboard.
  13. Next click on Add
  14. Check after 30 or so minutes, by visiting your url e.g to see if it worked.
  15. To see how your website appears to the rest of the world while you wait for the settings to take full effect visit GeoPeeker and enter your domain name in the search box.