30

So I've followed the instructions in this excellent guide for setting up a redirect from sub.my-domain.com to my-domain.com/sub. I've checked and double checked my settings, but when I access sub.my-domain.com I get the error

404 Not Found

Code: NoSuchBucket
Message: The specified bucket does not exist
BucketName: sub.my-domain.com

If I go to sub.s3-website-eu-west-1.amazonaws.com (the bucket I created) it is redirected correctly, and I am 100% certain double-plus confirmed that the url in the CNAME Record Set is the correct one. What is going on?

It seems like BucketName in the error message is wrong, but why is this?

Community
  • 1
  • 1
fredley
  • 32,953
  • 42
  • 145
  • 236

3 Answers3

58

It's hard to tell since you (sensibly) obfuscated your question but the way you've written it, I think this is a case of not naming the bucket correctly for this application.

sub.s3-website-eu-west-1.amazonaws.com

If the web site is "sub.example.com," then that's not the correct convention, so I wonder if your bucket name is also not correct: the bucket should be named "sub.example.com" -- not "sub" -- and the web site endpoint should be sub.example.com.s3-website-eu-west-1.amazonaws.com.

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
  • 2
    Why the bucket name must be sub.example.com? – lu yuan Nov 10 '14 at 01:38
  • 3
    @luyuan because that's how S3 is designed. If your site name is "this.example.com" then S3 required that the content be stored in a bucket called "this.example.com". It cannot be a bucket called "this" or "example.com" or "mybucket" or anything else. It has to exactly match the hostname, and it must be lower case. – Michael - sqlbot Nov 10 '14 at 01:56
  • Actually i have the same problem. I used s3 to store images, and the bucket name is 'seeyoukee.1'. Now I wanna use a DNS CNAME 's3.aws.seeyoukee.com' to direct. Is there anyway to achieve this without modify my bucket name? – lu yuan Nov 10 '14 at 02:49
  • @luyuan there is no way do this unless you use an external proxy server to rewrite the request headers and proxy the response. S3's built-in capability requires the full hostname to match the full bucket name. – Michael - sqlbot Nov 10 '14 at 02:57
  • Is it possible to create a bucket 's3.aws.seeyoukee.com' and use 'Redirect all requests to another host name' feature to redirect all requests to the bucket 'seeyoukee.1'? – lu yuan Nov 10 '14 at 03:16
  • Yes, but I'm not sure what that accomplishes, since you will pay for each request twice and each request will take a little longer, since there will be additional time required to process the redirect. – Michael - sqlbot Nov 10 '14 at 13:07
  • As the s3 in Tokyo is blocked by China Government. It forces me to change s3 to another image storage service. The url is hardcoded in the App now. I would like to user a CNAME to replace the hardcoded url which can direct it to s3, and release a new version. After the new version released, I could transfer the images to another image storage service, and rebind the CNAME to the new storage service url. – lu yuan Nov 11 '14 at 08:10
  • @ Michael - sqlbot Thank you! I had the same issue and I have renamed the bucket so matches the domain name, and now works fine. – candino Apr 20 '17 at 14:22
2

You can fix it by renaming your bucket as "Michael - sqlbot" says.

But if you really want to keep your bucket name, then you can use CloudFront to forward requests to your existing bucket, and then use DNS to map the website name(s) to the CloudFront name.

CloudFront is another Amazon Web Service that caches HTTP requests to your bucket in caches all around the world, so your website will be faster :-). But you will have to pay more :-(.

Adam Gawne-Cain
  • 1,347
  • 14
  • 14
0

in my case

Code: NoSuchBucket

appeared because I tried to use js s3-client to copy folder from S3 bucket to other S3 bucket, instead of copying file and it doesn't support copying folders, that error message is very missleading!

Oleksandr Hrin
  • 757
  • 1
  • 10
  • 12