How to Setup Heroku with GoDaddy
I don’t know about you, but setting up domain configurations is one of the least fun parts about building and launching a site for me.
Setting up GoDaddy and Heroku was a particularly frustrating experience and I thought I’d try and help you avoid the same pitfalls.
As it turns out, it’s impossible to perfectly get Heroku and GoDaddy to play together well, but below is as close as you can get.
Why connecting GoDaddy and Heroku is challenging:
- Most platforms give you a CNAME record to point your www subdomain to, and then some IP Addresses for your A records to point to. Heroku only provides CNAME records and ANAME or ALIAS records GoDaddy does not have.
- You can add Custom Domains on the Heroku site, but the domain format isn’t clear, should I add the www subdomain and the “naked” domain, one, or the other?
- When you do add a Custom Domain in Heroku, the domain to point to is cut off on the Heroku website.
- SSL requires you to upgrade to a Hobby Plan in Heroku, and then https needs to still be managed somewhat carefully on the DNS side.
Initial Goals:
Going to:
http://yoursite.com
https://yoursite.com
http://www.yoursite.com
https://www.yoursite.com
All work and end up, without scary warnings, at https://www.yoursite.com
GoDaddy does NOT Support Heroku
Getting “https://yoursite.com” to go to your website without a scary warning is not something that is possible today when using GoDaddy.
Heroku documents why over here:
https://help.heroku.com/NH44MODG/my-root-domain-isn-t-working-what-s-wrong
Thank you @Aidlab for providing the link and context.
Final Solution Preview:
In Heroku:
1. The ONE domain you need to set up is the WWW version, www.your-site.com, do not set up your-site.com
2. Pay $7 a month to upgrade to the hobby plan because your site will load faster and you can have https://
In GoDaddy:
1. Add a CNAME record for “www” pointing to the site Heroku provides
2. Set up Domain Forwarding to point to the “https” version of your “www” domain.
Step by Step Guide:
In Heroku:
Step 1: Add your Custom Domain
Use the Heroku CLI to add your domain instead of doing it from the web application. Ensure you add the “www” version instead of just “yourdomain.com”
heroku domains:add www.yourdomain.com
Step 2: Retrieve the DNS Target
If it’s not already there, you can always type the following to get a list of your domains
heroku domains
Step 3: Double check SSL is enabled
If you’re like me and weren’t on a paid project when setting up your custom domain, you need to log in to Heroku and go to your Application Settings page and enable SSL.
In GoDaddy:
Step 0: Capture Original State
Before making changes, always take a screenshot or note of what settings looked like
Step 1: Remove Extraneous A Records
Remove any A records pointing to other IP Addresses from past projects or the GoDaddy defaults.
Step 2: Add a CNAME Record
Your CNAME record will have
Name = www
Value = Heroku domain from Step 2 above
Step 3: Set up Forwarding
Heroku mentions setting up ANAME or ALIAS records, GoDaddy does not have that. Instead, that is done through Forwarding. I personally spent way too long here trying to figure that one out…
You want to forward with the “https://” protocol to your “www” sub-domain.
In Conclusion:
Hopefully this saved you a few clicks and minutes. Like all domain stuff, there can be some nerve-wracking minutes while things propagate, but hopefully this will allow things to make much more sense!