Failed: DNS error: host unknown S3 + Cloudfront host static sites

0

Hi,

I'm new here, please guide me while i'm creating cloudfront & s3 bucket. sometimes after configure them got this error, while i cant get the solution i'm back using cloudflare. Since sometimes cloudflare being my issue, i tried using route53 and cloudfront for my static sites. Please help me, get solution for this issue.

error persist, while live test from google search console

Best Regards, Jacob

  • The DNS for the domain name in your screenshot is currently hosted by CloudFlare, not Route53. The IP addresses returned for your apex record are CloudFlare IP addresses. Are you chaining CloudFlare and CloudFront together?

asked 10 months ago239 views
2 Answers
0

I'll guide you through setting up an S3 bucket and CloudFront for hosting your static websites.

First, let's ensure that your S3 bucket is correctly configured for static website hosting:

  1. Create an S3 bucket or use an existing one.
  2. In the "Properties" section of the bucket, go to "Static website hosting" and enable it.
  3. Provide an index document (e.g., index.html) and an error document (e.g., error.html).
  4. Note down the "Endpoint" URL provided by AWS. This is the URL where your static website will be hosted.

Now, let's configure CloudFront to serve your static website from the S3 bucket:

  1. Go to the CloudFront service in the AWS Management Console and click "Create Distribution."
  2. Under the "Web" delivery method, click "Get Started."
  3. In the "Origin Domain Name" field, enter the Endpoint URL of your S3 bucket (from step 4 above).
  4. Leave the other settings as default or customize them as per your requirements.
  5. Create the CloudFront distribution.
  6. Once the distribution is deployed (this may take some time), note down the domain name provided by CloudFront (e.g., xyz.cloudfront.net).

The next step is to configure your domain name's DNS settings to point to the CloudFront distribution:

  1. If you're using Route53 as your DNS service, create an A record (or ALIAS record if using Route53) that points your domain to the CloudFront distribution domain name.
  2. If you're using a different DNS service, create a CNAME record that points your domain to the CloudFront distribution domain name.

After completing these steps and allowing some time for DNS propagation, your static website should be accessible through your domain name, served from the S3 bucket via CloudFront.

If you're still experiencing the "DNS error: host unknown" issue after following these steps, try the following troubleshooting steps:

  1. Check if your DNS settings have propagated correctly by using a tool like dig or nslookup.
  2. Ensure that your S3 bucket is publicly accessible (go to the bucket's "Permissions" section and check the "Block public access" settings).
  3. Verify that the CloudFront distribution has been deployed successfully (it may take up to 30 minutes).
  4. Check if there are any typos or misconfigurations in your DNS settings or CloudFront distribution.
profile picture
EXPERT
answered 10 months ago
0

Hello,

Please try this solution.

to set up an S3 bucket with CloudFront and Route 53 for your static web site.

Step 1 Create an S3 Bucket

  1. Open the S3 console.
  2. Click on "Create bucket."
  3. Enter a unique bucket name (Ex.my-website-bucket).
  4. Choose a region (EX.us-east-1).
  5. Leave the other settings as default and create the bucket.
  6. Upload your website files to this bucket.

Step 2 Enable Static Website Hosting on the S3 Bucket

  1. Go to the S3 bucket you just created.
  2. Click on the "Properties" tab.
  3. Scroll down to "Static website hosting" and click "Edit."
  4. Select "Enable."
  5. For the index document, enter index.html.
  6. Save changes.

Step 3 Create a CloudFront Distribution

  1. Open the CloudFront console.
  2. Click on "Create Distribution."
  3. Choose "Web" and click "Get Started."
  4. In the "Origin Domain Name," enter your S3 bucket's static website endpoint (EX. my-website-bucket.s3-website-us-east-1.amazonaws.com).
  5. Set the "Default Root Object" to index.html.
  6. Leave other settings as default and create the distribution.
  7. Note the CloudFront distribution domain name (EX.d1234abcd.cloudfront.net).

Step 4 Configure Route 53

  1. Open the Route 53 console.
  2. Click on "Hosted zones" and select your domain.
  3. Click on "Create Record."
  4. Select "A - IPv4 address" as the type.
  5. Enter your subdomain (e.g., www for www.example.com).
  6. Check the "Alias" box and select your CloudFront distribution from the dropdown.
  7. Save the record.

Step 5 Update Your Domain Registrar

  1. your domain registrar points to the Route 53 name servers for your hosted zone.
  2. This is usually done in your domain registrar's DNS settings.

https://dev.to/aws-builders/seamlessly-integrating-aws-s3-static-web-hosting-with-cloudfront-and-dns-configuration-an-in-depth-guide-553c

https://dev.to/aws-builders/guide-to-hosting-a-static-website-on-aws-using-s3-cloudfront-and-route53-with-just-7-steps-220b

EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions