Dustin Hoffman

This article was contributed by Dustin Hoffman

Dustin is a developer at Speakeasy, a place to find and create unique events.

Configuring Amazon Route 53 DNS for Your Heroku App

Last Updated: 26 March 2015

dns route 53

Table of Contents

The Domain Name System (DNS) is the internet’s routing layer responsible for mapping human-readable domain names (e.g., www.heroku.com) into machine addressable IP addresses (e.g.,

Amazon AWS’s DNS service is called Route 53 and is a highly available and scalable service. For users with existing AWS infrastructure components it may be convenient to utilize Route 53 as your DNS provider.

This guide will walk you through the steps of setting up your Heroku app’s DNS configuration on Route 53.


Before configuring your app’s DNS make sure you’ve used the Heroku CLI to attach your domain name to the application. This is necessary, in addition to the third-party DNS changes, to properly route traffic for specific domains to the right application on Heroku.

If you have not done so yet, attach the correct domain(s) to your app:

$ heroku domains:add example.com
$ heroku domains:add www.example.com

Be sure to specify all domains your application will serve, including subdomains.


As with any DNS provider, configuring your Heroku app’s DNS involves the following steps:

  1. Create a CNAME record to map from www.example.com to example.herokuapp.com or your SSL endpoint if using SSL.
  2. Establish a redirect from the root domain example.com to www.example.com to avoid the risks associated with root domains and A-records.
  3. Set Route 53 servers as the nameservers for your domain.

Route 53 uses different terms than standard industry parlance so this guide has non-trivial variance from other guides.

Hosted zone

A hosted zone is Route 53’s term for the collection of DNS records that make up a single domain’s configuration. You will need to create a hosted zone for each domain you wish to configure on Route 53.

Sign into the AWS management console and select the Route 53 service. Click the Create Hosted Zone button and supply the domain name you are configuring.

Create Hosted Zone

Use the root domain name for the hosted zone (e.g., example.com).

CNAME records

New records, such as the www CNAME record, are added in Route 53 as Record Sets. Select the newly created hosted zone for your domain and click on the Go to Record Sets button.

Go to Record Sets button

In the Record Sets view click the Create a Record Set button.

Create Record Set Button

This will display a form to specify a new record. Provide the name www and select the CNAME type.

If you are not securing your app with SSL enter the app’s default Heroku domain in the value field. Your app’s Heroku domain is just the Heroku app name followed by .herokuapp.com.

Create Record Set

If you are using an SSL endpoint to secure your app you will need to enter the your-endpoint-12345.herokussl.com endpoint URL in the value field instead.

Create SSL Record Set

Use the heroku certs command to determine your SSL endpoint URL if you’re unsure of its value.

$ heroku certs
Endpoint                 Common Name(s)       Expires                  Trusted

tokyo-2121.herokussl.com  www.example.com     2013-04-20 17:29:41 PDT  True

Click the Create Record Set at the bottom of the form to save the www CNAME record mapping.

Naked/root domain

Route 53 supports Alias records which use Amazon S3 static websites to dynamically resolve naked domains to their www counterparts using a 301 redirect. E.g. example.com to www.example.com.

Go to your AWS management, then open your S3 management console.

In order for the following bucket to appear when creating an Alias record in Route 53, you must name the bucket the exact same as the hosted zone. E.e. the hosted zone example.com and a bucket named example.com.

Create S3 Bucket

Select the newly created bucket, but don’t open it, click the “properties tab” and open the “Static Website Hosting” section.

Click “Redirect all requests to another host name”, www.example.com will be pre-filled. If it is not, enter www.example.com here.

Redirect settings

Save the redirect settings, then open your Route 53 hosted zone for example.com.

Create a new record set, leave the name blank, select A type. Turn alias to yes and select example.com from the S3 Website Endpoints section of the Alias Target dropdown.

Select S3 Bucket

Create the record set.

Congratulations, your domain example.com now redirects to www.example.com in a scalable way. Using Route 53 and Amazon S3 you’ve set up a naked domain which resolves to your Heroku Dyno’s even when their IP addresses are shifting.

Activate Route 53

At this point you’ve established the correct DNS configuration but no requests are using it. In order for Route 53 DNS to become active for your application you need to tell your domain registrar (GoDaddy, DNSimple, NameCheap, 1&1 etc…) to use your hosted zone’s Route 53 nameservers.

Go back to the Hosted Zones list and select your new hosted zone. There is a pre-populated Delegation Set section in the sidebar. These are the nameservers you need to provide your domain registrar for Route 53 to resolve your app domain.

NS Records

Refer to your registrar's instructions for updating the nameservers.

Supply this Delegation Set to your registrar to activate Route 53 for your application. It can take up to 24-48 hours for nameservers to become fully active.