Heroku, GoDaddy, HTTPS, and Root Domains: How To Set It Up
If you’re like me, you’ve probably stumbled across so many articles on connecting Heroku and GoDaddy.
And none of them did the trick.
I finally found a solution; by the time you finish reading this article, you should be able to:
- Have a secure connection in your app.
https://yourdomain.comas your root domain.
https://www.yourdomain.comto your root domain.
Why GoDaddy And Heroku Aren’t Compatible
Root domains on Heroku require the use of
However, they don’t exist on GoDaddy. That’s why it will never work properly!
I managed to find a few workarounds, but only
https://www.yourdomain.com worked fine here;
https://yourdomain.com was broken.
That’s really bad for the SEO, trust, and much more. All HTTP/WWW combinations must work.
Let’s set it up.
1. Add custom domains to Heroku
You need to add both domains here:
www.yourdomain.com. You need to enable the ACM as well.
You can do it with the CLI:
heroku domains:add yourdomain.com
heroku domains:add www.yourdomain.com
Or through their GUI, by opening the “Settings” tab for your app.
2. Create a Cloudflare account (it’s free)
You will actually get much more benefits from CDN, but that’s not the point of this article.
Just create a free account there. Click on “Add site”, enter
yourdomain.com, and finish the setup wizard.
For the DNS, you must input two records:
CNAME yourdomain.com *.herokuapp.comCNAME www yourdomain.com
The most important thing is to add your Heroku app domain here, not the one you can is in Heroku under “DNS Target” column! Otherwise, it won’t work well.
After that, you just need to set up redirects.
- Go to “Rules” tab.
- Click “Create a new rule”.
- Let the setting be “Forwarding URL”, with the status code 301. You want to redirect from
https://yourdomain.com. Enter those values into the input field.
- Don’t ignore this
/*, otherwise, your redirects won’t work well for any path inside the app — just the root.
3. Set up nameservers in GoDaddy
Open your domain in GoDaddy, then click “Manage DNS”.
You should remove GoDaddy’s nameservers, and add Cloudflare’s. You can find them in your website settings in Cloudflare, under the “DNS” tab.
Remove forwarding as well on GoDaddy (if you had any).
This is what your setup should look like:
4. Party 🎉
There’s no step #4, that’s it! You can test your domain with
curl -I yourdomain.com, and
curl -I www.yourdomain.com.
If you want it visual, just open an incognito window and input manually all four HTTP/WWW combinations from the beginning. They will all work and redirect you to
I hope that I saved you a couple of hours/days!