How to Set Up A Custom Domain on Heroku

12.22.2014

For this post, I’m going to use DreamHost as the domain provider. This process is usually similar for other domain providers as well.

Step 1: Purchase Domain

The first step is to purchase the domain. I use DreamHost for my domain purchases.

Step 2: Point CNAME

    1. Log in to DreamHost
    2. Click on Manage Domains
    3. Click on “DNS” of the domain you want to use
    4. Under “Add a custom DNS record to [your domain]:”
      • Type in “www” for Name
      • Select “CNAME” for Type
      • Type in your Heroku app URL (example.herokuapp.com) for Value
    5. Click “Add Record Now!”

Step 3: Redirect Root Domain to WWW

This step is necessary to redirect anyone trying to reach your root domain.

  1. Go to Manage Domains
  2. Edit your domain
  3. Under Redirect, redirect your-domain.com to www.your-domain.com

Step 4: Add Domain to App

Next you will want to add the domain to the Heroku app. You can do this from the Heroku web panel or the command line.

From the command line:

$ heroku domains:add www.example.com

Step 5: Wait

Don’t stress out. It usually takes a while before things start to work because of DNS propagation or whatever.

If you don’t want to use a subdomain, and would prefer root domain, example.com vs www.example.com, you would would have to go with another DNS provider like DNSimple and use the ALIAS record type instead of CNAME. Though it is more expensive because of monthly fees.

Sources

http://robandlauren.com/2013/02/21/pointing-a-dreamhost-domain-to-heroku/
https://devcenter.heroku.com/articles/custom-domains