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) yourdomain.tld
c) test.yourdomain.tld or any other subdomain
d) *.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 <<i>app-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: .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:

RecordNameTarget
CNAMEwwwwhispering-willow-5678.herokudns.com
CNAMEothersubdomainautumn-sunset-1495.herokudns.com
CNAMEexamplesecureexample-2121.herokussl.com
CNAMEexamplesecure-euexample.herokuapp.com

5. Now you can start configuring your domain from Namecheap's side if it uses our BasicDNS, 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:



We have implemented a new type of records called ALIAS record. Using this record, you can point your bare domain name to Heroku directly as contrary to the CNAME record, it can coexist with MX/MXE records for the same Host name and doesn’t influence the email service performance.

The important point here is that it is possible to install an SSL certificate for the root domain when it is connected to Heroku by means of the ALIAS record. In this case, your setup for the bare domain name should look in the following way:



(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.

Please NOTE: You can use ALIAS record to substitute the URL redirect records in the scenarios b and c, so that your root domain and subdomain point to the same destination. The step-by-step instructions for the ALIAS record setup can be found in the "How to create an ALIAS record" article.

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.

Keep in mind that the.app, .dev and .page domains (that must have SSL installed) may require the SSL Endpoint option to be used for free Heroku subscriptions to install the SSL certificate, otherwise, the domain will not work.
 

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

Updated
Viewed
77568 times

Need help? We're always here for you.

notmyip