Start a conversation

Set up DNS records for Heroku

Heroku is one of the most popular platforms for fast application deployment in Java, Node.js, Ruby, Clojure, Python and other languages.

If you have your own domain, you can use it instead of the default domain "example.herokuapp.com". And if you don't have a domain, you can always buy it 😉.


Set up custom domain on Heroku


First of all, you need to get records for your domain. To do this, you need to add your domain in the terminal:

$ heroku domains:add www.example.com

Then you will need to execute the next command:

$ heroku domains
=== example Heroku Domain
example.herokuapp.com

=== example Custom Domains
Domain Name      DNS Target
—————-----  --------------------------
example.com      hidden-sierra-7936.herokudns.com
www.example.com  whispering-willow-5678.herokudns.com

You should get a similar picture: a list of your domains and the "DNS Target" value. This will be the host alias for the CNAME record.


Set up domain on NIC.UA


Now that you have the records, it's time to configure the domain. First, you have to make sure that the domain uses NIC.UA name servers:

  • open the "Domains" section;
  • click on the gear next to your domain.

Find the "NS-Servers" section. Make sure "NIC.UA name servers" is selected there. If not, select them and click "Change NS".
Now all you have to do is configure the DNS records:

  •  open the "Name servers" section;
  • click on the gear near the name servers;
  • on the page that opens click on "Change" in the table of DNS records.

You will need to delete all records with type "A" and create new records:

  • Record for a root domain
    • name: @
    • type: Permanent Redirect
    • URL: http://www.example.com
  • Record for a subdomain, that you added to Heroku: 
    • name: www
    • type: CNAME
    • host alias: whispering-willow-5678.herokudns.com.
    • ⚠️Please note: the dot after host alias is mandatory; you will get your own host alias by executing terminal command «heroku domains».

All we have to do now is wait for your ISP's DNS cache to be updated. It usually takes from a couple of hours up to a day.

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Eldar Polishchuk

  2. Posted

Comments