ERROR -- : Response was: 307 -- Temporary Redirect when trying to upload to bucket

I get 307 when uploading to a bucket with Amazon's Ruby gem (2.10.2). Another bucket works fine (both were created today). I checked the name and I didn't misspell it. What is causing the error?


307 is the HTTP code for "Temporary Redirect". Per the S3 docs on such redirects:

Temporary Request Redirection

A temporary redirect is a type of error response that signals to the requester that he should resend his request to a different endpoint.

Due to the distributed nature of Amazon S3, requests can be temporarily routed to the wrong facility. This is most likely to occur immediately after buckets are created or deleted. For example, if you create a new bucket and immediately make a request to the bucket, you might receive a temporary redirect, depending on the location constraint of the bucket. If you created the bucket in the US East (N. Virginia) region (s3.amazonaws.com endpoint) you will not see the redirect because this is also the default endpoint. However, if bucket is created in any other region, any requests for the bucket will go to the default endpoint while the bucket's DNS entry is propagated. The default endpoint will redirect the request to the correct endpoint with a HTTP 302 (sic) response.

The claim that 302s are used for these redirects seems to be an error in the docs, since it contradicts both the behaviour you have witnessed, the behaviour I have witnessed, and the "Example REST API Redirect" later in the same page of the docs.

So your options are:

  • If you face no urgency, just wait; it will fix itself within a few minutes or hours.
  • If you need these redirects to never occur, create all your buckets in the US East region.
  • If neither of the above is an option, ensure that whatever HTTP clients you are using to access the buckets are capable of following the Location: header in the redirect and configured to do so.

Waiting didn't help in my case - I had to invalidate everything with path "/*" in the AWS cloudfront console to fix the 307 with subsequent "Access denied" on the forward to the private S3 bucket.