Custom Domain Names on Heroku

A while back, I wrote about how to deploy Sinatra applications to Heroku. I still think Heroku is the best option for deploying Sinatra apps and use it for all of mine. They have free plans for experimenting, but can also scale to the largest apps.

One problem is that all the apps are hosted as a sub-domain of For example, last week, I wanted to set up my personal site dazzl on heroku, but the address was This is fine, but I own the domain so it makes sense to use this, as well as looking more professional.

Custom domain names can be used in Heroku using the Custom Domains addon and the Zerigo addon.

The first thing I did was to change the nameservers to point to Zerigo’s servers.

Some registrars let you do this yourself online (mine did), but you might have to contact some to ask them to do this.

The next job is to install the Custom Domains addon and the Zerigo addon. You can add these either from the Heroku website or from the console. To use the console, just open up a terminal window and type the following.

> heroku addons:add custom_domains:basic
> heroku addons:add zerigo_dns:basic

The last job is to setup the domains you want to add. I would reccomend using the domain and the www. sub-domain, as follows:

> heroku domains:add
> heroku domains:add

And that’s it! My site is now accessible from as well as

You can also use the Zerigo management interface (accessed through your Heroku dashboard) to add CNAME entries. This can help you set up aliases and sub-domains to point to more complicated links.

For example, say I wanted to be have the easier alias of

First I need to log into my Heroku account, select the dazzl app, then select the Zerigo addon from the:

Screenshot 1

The following screen should appear. Just click on the Configure button:

Screenshot 2

This takes you to Zerigo’s online management console. To add a CNAME entry, you need to click on the + add button, just underneath the green ‘Hosts’ tab shown below:

Screenshot 3

Last of all, you just need to fill in the form. You only need to fill in two entries - leave all the others as they are. Put the sub-domain you want to use in the first text field marked Host. Then put the full path (omitting http://www.) where you want it to link to in the text field marked Data. You can see my form in the screenshot below:

Screenshot 4

As you can see, it’s really simple to set up custom domain names on Heroku.

blog comments powered by Disqus