Learn Django

Purchase & Configure Domain Name

Owning and configuring a custom domain is a requirement if you want to run a SaaS application. There are many providers who can provide you with this service. However, not all of them make it easy to work with Heroku. Luckily there are some that do.

This lesson will show you how to register a domain name and configure it using DNSimple. You only have to follow the steps here if you want to register your own domain. Note that there registering domain names does have an extra cost.

1. Purchase a domain name

The first step is to go to https://dnsimple.com/ and create an account. Once you have an account you can register a custom domain. That page will guide you through the process of buying a domain.

Create record for staging

Once you have a custom domain you can create the DNS records. The first record to create is for staging.

In order to create the record for staging you need to know what the DNS name is. The DNS name of any Heroku app is in the format of http://app-name.herokuapp.com/. If you have the app name you can figure out the DNS name.

So the first step is to get the app name for staging. Open a terminal and run this command.

1
2
3
4
5
6
# list all remotes
(venv)$ git remote -v
prod    git@heroku.com:arcane-caverns-9181.git (fetch)
prod    git@heroku.com:arcane-caverns-9181.git (push)
staging git@heroku.com:glacial-wildwood-4145.git (fetch)
staging git@heroku.com:glacial-wildwood-4145.git (push)

In the example above, glacial-wildwood-4145.herokuapp.com would be the DNS name for the staging app.

With that in hand you can create the DNS record. Open the DNSimple domain management tool. Click on the edit button under the DNS Record section. You need to create one CNAME record. Click the yellow 'Add Record' button, select CNAME from the drop down. On the next screen type staging in the Name box, and the app DNS name (found above) in the Alias for box. Here's an example.

Then open a terminal and issue this command to configure Heroku to recognize the DNS name. You will need to change the command for your domain and Heroku app. For example, if your domain name was 'allawesome.com', and your app was bamboo-grows-1234, then the command would be heroku domains:add staging.allawesome.com --app bamboo-grows-1234.

1
2
3
# add the custom domain
(venv)$ heroku domains:add staging.crmeasyapp.com --app glacial-wildwood-4145
Adding staging.crmeasyapp.com to glacial-wildwood-4145... done

You should now be able to to access http://staging.yourdomain.com/.

Create records for production

There are two DNS records to create for production. The first step is to get the production DNS name. Determine it just like you did for the staging app. Run this command.

1
2
3
4
5
6
# list all remotes
(venv)$ git remote -v
prod    git@heroku.com:arcane-caverns-9181.git (fetch)
prod    git@heroku.com:arcane-caverns-9181.git (push)
staging git@heroku.com:glacial-wildwood-4145.git (fetch)
staging git@heroku.com:glacial-wildwood-4145.git (push)

In the above example the production app DNS name is arcane-caverns-9181.herokuapp.com.

Next go to the domain management tool and create two records:

1st Record
Type: Alias
Name: leave it blank
Alias for: www.yourdomain.com e.g. www.crmeasyapp.com

2nd Record
Type: CNAME
Name: www.crmeasyapp.com
Alias for: your-app.herokuapp.com e.g. polar-eyrie-6243.herokuapp.com

All of your records should look like this:

Track your progress with a free account