amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

Redirects from your root domain to www does not work

Open jacobsapps opened this issue 3 years ago • 27 comments

Before opening, please confirm:

App Id

Let me know if it matters

Region

us-east-1

Step

Domain Redirects

Status

Partial failure

Issue or question

My SEO is getting wrecked because we don't have a functioning domain for https://domain.com.

The https://www version works fine, as well as the http:// and http://www. version, but https:// on its own gets either ERR_CONNECTION_TIMED_OUT or ERR_CONNECTION_REFUSED depending on what configuration of redirect rules I have.

Right now we have the following configuration. I've tried multiple other approaches like removing the root domain from domain management and trying to rely just on redirects, I've also tried using alternative redirect types like 200 (rewrite) and 301 (permanent).

Nothing's working.

Error message

ERR_CONNECTION_TIMED_OUT / ERR_CONNECTION_REFUSED

Additional information

Screenshot 2022-01-20 at 17 27 33 Screenshot 2022-01-20 at 17 27 38

jacobsapps avatar Jan 20 '22 17:01 jacobsapps

Hi :wave:, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

github-actions[bot] avatar Jan 20 '22 17:01 github-actions[bot]

+1 I've got a custom domain and have already migrated DNS to Route53, had the redirect rules set in AWS Amplify

The problem I face however is DNS_PROBE_FINISHED_NXDOMAIN not timeout

dig +trace shows ...... foobar.app. 10800 IN NS ns-670.awsdns-19.net. foobar.app. 10800 IN NS ns-1927.awsdns-48.co.uk. foobar.app. 10800 IN NS ns-1238.awsdns-26.org. foobar.app. 10800 IN NS ns-64.awsdns-08.com.

foobar.app. 900 IN SOA ns-1238.awsdns-26.org. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400

any pointers will be appreciated! Thank you! :)

lijameshao avatar Jan 22 '22 22:01 lijameshao

Never mind found a way around and got it working 🤣

  1. In Route53, manually create an A record, for the root domain, tick Alias, Route traffic to "Alias to CloudFront distribution"
  2. When clicking the drop down, it didn't show any options so I just manually entered the xxxxxxxxx.cloudfront.net from AWS Amplify Console, Domain management, Actions, View DNS record

Screenshot 2022-01-22 at 23 10 37

lijameshao avatar Jan 22 '22 23:01 lijameshao

Never mind found a way around and got it working 🤣

  1. In Route53, manually create an A record, for the root domain, tick Alias, Route traffic to "Alias to CloudFront distribution"
  2. When clicking the drop down, it didn't show any options so I just manually entered the xxxxxxxxx.cloudfront.net from AWS Amplify Console, Domain management, Actions, View DNS record

Screenshot 2022-01-22 at 23 10 37

I have the domain and DNS set up in GoDaddy - I'm not sure I have access to those features. Have you got any ideas?

jacobsapps avatar Jan 24 '22 09:01 jacobsapps

Never mind found a way around and got it working 🤣

  1. In Route53, manually create an A record, for the root domain, tick Alias, Route traffic to "Alias to CloudFront distribution"
  2. When clicking the drop down, it didn't show any options so I just manually entered the xxxxxxxxx.cloudfront.net from AWS Amplify Console, Domain management, Actions, View DNS record

Screenshot 2022-01-22 at 23 10 37

I have the domain and DNS set up in GoDaddy - I'm not sure I have access to those features. Have you got any ideas?

I had a domain on GoDaddy too and unfortunately gave up trying to get the DNS working there, so instead migrated the DNS to Route53

In your case, the question is how does your GoDadddy record know what's the IP of your AWS cloudfront is if it's not static, assuming that you don't currently have your IP dynamically mapped? As far as I know GoDaddy doesn't currently support ANAME record

If you're going to migrate your DNS, just a heads up that your website could be offline for a while, so remember to lower the TTL

lijameshao avatar Jan 24 '22 09:01 lijameshao

Hi @jacobsapps 👋🏽 apologies for the delay. It's suggested in the documentation that you migrate your DNS to Route53 in order to configure your root domain since GoDaddy doesn't support ANAME/ALIAS records. The workaround would be to setup a domain forward in GoDaddy. Please see step 6 of Add a custom domain managed by GoDaddy.

ghost avatar Feb 02 '22 21:02 ghost

Hi @jacobsapps 👋🏽 apologies for the delay. It's suggested in the documentation that you migrate your DNS to Route53 in order to configure your root domain since GoDaddy doesn't support ANAME/ALIAS records. The workaround would be to setup a domain forward in GoDaddy. Please see step 6 of Add a custom domain managed by GoDaddy.

Even after setting the domain forward in GoDaddy, still facing the same issue. Any workaround would be much appreciated

prashidi avatar Jun 02 '22 17:06 prashidi

I am facing the same issue with my DNS. I have set up the forwarding as follows (image). image

gog1withme avatar Jun 27 '22 05:06 gog1withme

Still facing this issue. I have tried all possible options to resolve this including adding a permanent redirect, rewrite etc. Still no luck with getting non-www working on the root domain.

nagarjunkinare avatar Aug 13 '22 03:08 nagarjunkinare

Facing the same issues aswell, domain.com is not being redirected to www.domain.com

hasan-hype avatar Nov 22 '22 07:11 hasan-hype

Same as everyone else.

SG57 avatar Nov 28 '22 09:11 SG57

Same here

alexcharles44444 avatar Dec 01 '22 21:12 alexcharles44444

Same problem. Please, send any instructions

pavellevchuk avatar Dec 14 '22 13:12 pavellevchuk

I fixed it! My problem was I was using AWS Amplify and didn't add the non-www url to the custom domain list in the amplify console under "Domain Management" like so: image

Then it will have problems adding an extra / at the end of the non-www url, which will break paths to any external images/scripts, so to fix that, you add this under "Rewrites and Redirects" image

alexcharles44444 avatar Dec 30 '22 21:12 alexcharles44444

I was facing same issue but found a cure with the help of @lijameshao who has already replied above.Just add @.example.com and choose alias and problem will be solved

PlexSpark avatar Jan 08 '23 08:01 PlexSpark

This is from the godaddy forum: @KinaHus That's correct, the forwarding service is not currently compatible with HTTPS. As the forwarding service uses a server to do the redirect it would need to be covered by an SSL certificate for your domain name, which isn't possible at this time.

Does anyone know where the idea to use godaddy even came from?

plov avatar Feb 09 '24 02:02 plov

I've noticed this issue recently when the UI and location of functions has changed on the recent AWS Amplify update. Didn't have this issue before when im setting up my domain in amplify, then recently i got this issue where root domain didnt get automatically redirected to www.

My solution is like this which might help someone so im posting it here. Screenshot 2024-05-15 at 11 27 49 AM The 1st record on this image is URL1 which is working fine, URL2(last record) on the other hand is having the issue. after moving URL2 above the 2 records with Target Address: /index.html then save it will now automatically redirect root domain to www.

Hope this helps someone.

michaeldino27 avatar May 15 '24 03:05 michaeldino27

@michaeldino27 This worked for me! thanks!

kennethlorenz avatar May 23 '24 19:05 kennethlorenz

@michaeldino27 This worked for me! thanks!

Happy to help!

michaeldino27 avatar May 25 '24 09:05 michaeldino27

In my case, I had an AAAA record in Route53 that I had to remove.

f19ps avatar Jun 04 '24 12:06 f19ps

@michaeldino27 Thanks very much, this works!

TakundaHwaire avatar Jul 13 '24 13:07 TakundaHwaire

@michaeldino27 I tried this and couldn't get it to work. Clearly it's working for others so I must have something wrong.

May I ask what your "Custom Domains" tab looks like? And what your relevant entries in Route 53 look like?

I keep getting DNS errors where it can't resolve the host for the root name.

For Amplify devs, maybe you guys could write some sort of trouble shooting tool for this? Right now we edit this page, hit Save and it says "Updating app: success" then proceeds to not work.

jpangburn avatar Jul 16 '24 18:07 jpangburn

@jpangburn

Have a look here. Custom Domain

Can you also show your Rewrites & Redirects so i can have a look as well?

michaeldino27 avatar Jul 17 '24 02:07 michaeldino27

@michaeldino27 Hmm, that's different! I don't have that first one. I wonder if that's the problem. As it stands, I have the following settings: Custom domains: customdomain

Rewrites and redirects: redirects

Route 53: route53

I made the change like you showed on your custom domain so it looks like: updated_customdomain

In route 53, that added a record: updated_route53

After this was complete, I can now go to the root URL and under the hood it works like going to www.rooturl.com as there's a 302 redirect, so all the referrers in the HTTP headers show www. The funny thing was, I tried adding that DNS record manually yesterday because I thought it just needed an A record aliased to cloudfront, but it didn't work despite looking exactly like what Amplify generated. I think you really need that redirect in Amplify rather than manually putting the A record alias in Route 53, maybe it tells Cloudfront something else we don't see here.

Thank you so much for your help! Hope my notes here help someone else who screwed their configuration up similar to me haha

jpangburn avatar Jul 17 '24 16:07 jpangburn

@jpangburn yeah i have also tried playing around Route 53 prior discovering the solution. Glad the solution worked on you!

Just hoping that amplify team would be able to fix this soon, it used to be automatic but now have to do extra step to make it work. XD

michaeldino27 avatar Jul 18 '24 02:07 michaeldino27

I've tried it again on a new branch and it did it automatically already! thanks amplify team!

michaeldino27 avatar Jul 24 '24 02:07 michaeldino27