Pointing a domain to the Heroku app

When you create an app on Heroku, it can be accessed via Heroku Domain. For example, if you have built an app with the name "nctesting", you can enter http://nctesting.herokuapp.com in a browser, and your website will be displayed.

It is also possible to make your app accessible via a custom domain that is registered with Namecheap. Here you can add custom domains to both free and paid Heroku accounts.

Domains can be inspected and managed using either Heroku CLI or Dashboard.

1. First of all, preconfigure your Heroku app to be used with your custom domain.

Deploy your app and make sure it is working via your Heroku subdomain: example.herokuapp.com. If you are having difficulties deploying your Heroku app, feel free to refer to Heroku documentation.

2. Verify your Heroku account by adding a credit card to it.

3. Once the account is verified, you will be able to add a custom domain.

4. Now let's decide what you want to be displayed in the URL after the setup. You can have it displayed as the following:

a) www.yourdomain.tld
b) test.yourdomain.tld or any other subdomain
c) *.yourdomain.tld (a wildcard)

Depending on the domain name you select, its settings will be adjusted. Please keep in mind that the required CNAME values can be obtained on the Heroku side.

  • If your application is in a Private Space
The DNS target will be of the format <app-haiku-nr>.<space-haiku-nr>.herokuspace.com.

  • If your application uses the SSL Endpoint addon
There are two possible scenarios in this case, depending on the region:

   - For applications hosted in our US region, the CNAME target will be: endpoint_name.herokussl.com.

   - For applications hosted in our EU region, the CNAME target will be: your_app_name.herokuapp.com.

  • If your application uses a new Heroku SSL or Automated Certificate Management
The exact CNAME target is randomly generated but it will be in the format: <random-haiku-string>.herokudns.com.

  • If your application is only accessible via HTTP and does not use any SSL
   - Custom Domains previously created when herokudns.com was available will be displayed as your_app_name.herokuapp.com with the DNS CNAME target.

   - Custom Domains recently created will be displayed as your_custom_domain.herokudns.com with the DNS CNAME target.

Below you will find find a table of the common records patterns:

Record Name Target
CNAME www whispering-willow-5678.herokudns.com
CNAME othersubdomain autumn-sunset-1495.herokudns.com
CNAME examplesecure example-2121.herokussl.com
CNAME examplesecure-eu example.herokuapp.com

5. Now you can start configuring your domain from Namecheap's side if it uses our BasicDNS, BackupDNS (a legacy option), PremiumDNS or FreeDNS. If your domain uses other nameservers, it’s necessary to make changes on the side of your hosting/DNS provider.

In order to do this, please follow the listed steps:

- Sign in to your Namecheap account.

- Select Domain List from the left navigation sidebar and click on the Manage button that appears in front of your domain name:
 

- Now click on the Advanced DNS tab and locate the Host Records section. Use the Add New Record button to add the required records (are you unable to edit host records?):


In this section, you will need to create several host records for your domain name. Please keep in mind that the DNS values may be different for each domain name depending on the way your application is set up.
 
To configure the required records in your Namecheap account, please do the following:

(a) To use www.yourdomain.tld and yourdomain.tld, the following host records should be created:

URL Redirect Record for @ to forward to http://www.[yourdomain.tld]
CNAME Record for www mapped to the values provided by Heroku:


(b) To use any other subdomain, like test.yourdomain.tld and yourdomain.tld, you should create the following records:

URL Redirect Record for @ to forward to http://test.[yourdomain.tld]
CNAME Record for test mapped to values provided by Heroku:


PLEASE NOTE: You can replace the test with any subdomain that you like.

If only the subdomain (subdomain.yourdomain.tld), not the root domain itself (yourdomain.tld) should be mapped to Heroku (e.g., the root domain is using some other hosting service), there is no need to add the URL Redirect Record. The CNAME record, which points to the values provided by Heroku, is enough.

(c) To use *.yourdomain.tld and yourdomain.tld, the following host records should be created:

URL Redirect Record for @ to forward to http://www.[yourdomain.tld]
CNAME Record for * mapped to the values provided by Heroku:


Once all the records are configured, save them using the Save all changes button. It may take up to 30 minutes for the changes to come into effect.

6. Make sure that there are no conflicting records set for the same host.

If there are any conflicting records, please remove them. You need to pay attention to the records of the following types: URL Redirect (Unmasked/Masked/Permanent Redirect), A or CNAME. For example, you need to check if you have the default host records such as URL redirect and CNAME pointing to Namecheap parking page.

Here is an example of conflicting host records:


 Good news! You now know how to point a domain name to the Heroku app.


If you have any questions, feel free to contact our Support Team.

Comments

We welcome your comments, questions, corrections and additional information relating to this article. Your comments may take some time to appear. Please be aware that off-topic comments will be deleted.

If you need specific help with your account, feel free to contact our Support Team. Thank you.

Need help? We're always here for you.

× Close