Adding Custom Domain Name


Jade Danial


08 02, 2020 11:17 AM


0 feedbacks



A customized domain name helps you to establish your blog as a professional brand. It also ensures a blog’s success in multiple areas, search engine rankings, quality traffic, Google Adsense approval, community building and more. Every blog is special, but it needs to be discovered first.



Today I bought a domain name from which is "" and I bought it for $5 for 1 year.



For my Heroku app to be available in my custom domain "", I need to point my custom domain to my Heroku app URL. To achieve this I need to add my custom domain to Heroku which will give me a DNS target domain. The DNS target domain can then be added to my domain hosting site's CNAME. And this will make my app available at "" and "".




Modify File



Before anything else, I need to modify my file to add my custom domain name in the ALLOWED_HOSTS  which is "":


ALLOWED_HOSTS = ['', '', '']



After modifying my file I push it to my Github and Heroku account by running the command:


git status
git add .
git commit -m "Update for ALLOWED_HOSTS added custom domain."
git push origin master
git push heroku master



That's it, my app is ready to add a custom domain name.




Adding Custom Domain Name


First things first I go to the dashboard in Heroku.


I click my app name and then I click the "Settings".


Then I click on the button "Add domain".


After that a small screen pop-up then I type in the text field "" then I click the "Save changes" button.


I add also another domain "" for the Alias name without "www"


After the above steps, a two DNS target added.


I go to and log in to my account.


Then I click "Domain Management" under my username.


In my custom domain, I click the "Edit" below the DNS Records, then a Manage DNS Records screen appeared.


In the Type field I choose "ALIAS - CNAME flattening record".


In the Host field, I leave it blank.


In the Answer field, I put the DNS target from Heroku where the domain name without "www" which is "" only.


Then I click the button "Add".


I add another record which is Type "CNAME - Canonical name record".


In the Host field, I type "www".


In the Answer field, I put the DNS target from Heroku where the domain name contains "www" which is "".


Then I click the button "Add".



That's it! After a few minutes, my Heroku app is available in the custom domain name "" and "".





Please feel free to submit the feedback below. I appreciate it.


Thank You and Happy Coding.

0 Feedbacks


Jade Danial is a passionate programmer and creator of Code Hub blog. He is fueled by his passion for learning. He is fascinated by the idea of discovering the world of programming.

Meanwhile, he is developing desktop and web applications using his skills in programming.

Get In Touch With Me