如何将Namecheap根域名配置到Heroku Hobby级Dyno实例
Got it, let's walk through getting your Namecheap domain asdf.com pointed to your Heroku Hobby app smoothly—since you already have ACM enabled and the app is working at https://asdf.herokuapp.com/, we just need to tie the domain to Heroku and configure DNS correctly.
1. Add Your Domain(s) to Heroku
First, let's register your domain with Heroku so it recognizes it and issues the SSL certificate:
- Open your Heroku dashboard, navigate to your app's Settings page
- Scroll down to the Domains and certificates section, click Add domain
- First, enter your root domain
asdf.comand hit Next—Heroku will generate a unique DNS target (looks likexxxx-xxxx-xxxx.herokudns.com). Save this target, you'll need it later. - Repeat the process to add the
www.asdf.comsubdomain, and save its DNS target too.
2. Configure DNS Records in Namecheap
Now let's point your Namecheap domain to Heroku:
- Log into your Namecheap account, go to your Domain List
- Find
asdf.comand click Manage next to it - Switch to the Advanced DNS tab, then set up these records:
For the root domain (
Namecheap doesn't support ALIAS/ANAME records (which are ideal for root domains), so you have two solid options:asdf.com)- Option 1 (Recommended): Redirect root to www
- Add a URL Redirect Record:
- Host:
@ - Value:
https://www.asdf.com/ - Redirect Type: Permanent (301)
- TTL: Automatic
- Host:
- Add a URL Redirect Record:
- Option 2: Use Heroku's static IP addresses
- Note: Heroku's IPs might change occasionally, so you'll need to check for updates if you go this route. Add four A Records:
- Host:
@ - Value:
50.16.248.154 - Host:
@ - Value:
50.16.249.154 - Host:
@ - Value:
50.17.203.154 - Host:
@ - Value:
54.235.183.154
- Host:
- Note: Heroku's IPs might change occasionally, so you'll need to check for updates if you go this route. Add four A Records:
- Option 1 (Recommended): Redirect root to www
For the
wwwsubdomain- Add a CNAME Record:
- Host:
www - Value: The DNS target Heroku gave you for
www.asdf.com(e.g.,xxxx-xxxx-xxxx.herokudns.com) - TTL: Automatic
- Host:
- Add a CNAME Record:
- Don't forget to click Save All Changes at the bottom!
3. Verify SSL Certificate Deployment
Since you have ACM enabled, Heroku will automatically issue an SSL certificate for your new domains once DNS propagates:
- Head back to your Heroku app's Domains and certificates section
- You'll see
asdf.comandwww.asdf.comlisted—wait 5-10 minutes (sometimes up to an hour) for a green checkmark to appear next to them, indicating the certificate is active. - If it's taking too long, double-check your DNS records with terminal tools:
- Run
dig www.asdf.com CNAMEto confirm it points to the correct Heroku DNS target - For the root redirect, run
curl -I https://asdf.comto ensure it sends a 301 redirect towww.asdf.com
- Run
4. Test the Full Setup
- Give DNS changes 10-15 minutes to propagate (it can take longer depending on your TTL settings)
- Visit
https://www.asdf.comandhttps://asdf.com—both should load your Heroku app over HTTPS with no certificate errors - Quick sanity check: Push a small change to your GitHub repo to confirm the integration still works (domain changes shouldn't affect this, but it's always good to verify)
内容的提问来源于stack exchange,提问作者simon
相关产品推荐
相关产品推荐

