GoDaddy CNAME记录无法适配Heroku DNS目标问题求助
Hey Rodrigo, let's break down the most common issues that could be preventing your www.rodrigoloza.com domain from working properly with your Heroku-hosted Django app. Let's go through each step one by one:
Verify DNS Propagation
Since your TTL is set to 1 hour, DNS changes can take up to that full window to roll out across global servers. To check if your CNAME record is active, run one of these commands in your terminal:nslookup www.rodrigoloza.com # or dig www.rodrigoloza.com CNAMEThe output should show
rodrigoloza.com.herokudns.comas the canonical name. If it doesn't, wait a bit longer for propagation, or double-check your GoDaddy DNS entry for typos.Confirm Heroku Domain Configuration
You already ranheroku domains -a rodrigo-blog-123456to check the association, but make sure the DNS Target listed exactly matches the value you entered in GoDaddy's CNAME record (rodrigoloza.com.herokudns.com). Even a single typo (like missing a.comor extra character) will break the connection.Update Django's ALLOWED_HOSTS
A super common gotcha with Django apps on Heroku is forgetting to add your custom domain to theALLOWED_HOSTSsetting insettings.py. If this is missing, Django will reject requests from your domain, usually throwing a 400 Bad Request error. Update your setting to look like this:ALLOWED_HOSTS = [ 'www.rodrigoloza.com', 'rodrigo-blog-123456.herokuapp.com' ]After making this change, redeploy your app to Heroku with
git push heroku main(or your main branch name).Enable Heroku SSL
If you're trying to access your domain over HTTPS (which is recommended), you need to ensure Heroku has an SSL certificate for your custom domain. Heroku offers free automated SSL for custom domains—enable it with this command:heroku certs:auto:enable -a rodrigo-blog-123456This will provision a certificate and ensure all requests redirect to HTTPS, avoiding certificate errors or insecure connection warnings.
Check for Conflicting DNS Records
In GoDaddy's DNS manager, make sure there are no other records for thewwwsubdomain (like an A record pointing to an IP address) that might be overriding your CNAME. Delete any duplicate or conflicting entries forwwwto ensure only your correct CNAME is being used.Clear Browser/Network Cache
Your browser or local network might be caching old DNS data. Try accessing your domain in a private/incognito window, or test from a different device/network to rule out cached records.
内容的提问来源于stack exchange,提问作者Rodrigo Loza

