About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When a backup tool or the AWS CLI fails with PermanentRedirect, S3 is telling the client that it sent the request to the wrong endpoint for that bucket. The S3 API Reference lists the code with the description "The bucket you are attempting to access must be addressed using the specified endpoint. Send all future requests to this endpoint." and "HTTP Status Code: 301 Moved Permanently". The cause we find most likely, from the AWS CLI and head-bucket pages, is a Region mismatch: the client is configured for one Region and the bucket lives in another. The API page does not say so. The head-bucket call tells you the bucket's Region.
What the error means
Amazon S3 buckets belong to one Region, and each Region has its own endpoint. The AWS General Reference lists them; the Asia Pacific (Sydney) Region, ap-southeast-2, has the endpoint s3.ap-southeast-2.amazonaws.com.
The User Guide gives two ways to address a bucket. Path-style is https://s3.region-code.amazonaws.com/bucket-name/key-name, and virtual-hosted-style is https://bucket-name.s3.region-code.amazonaws.com/key-name. It says "Currently, Amazon S3 supports both virtual-hosted-style and path-style URL access in all AWS Regions."
The AWS CLI page ties path-style to the Region setting: "If you set the addressing style to path, you must ensure that the AWS region you configured in the AWS CLI matches the same region of your bucket." Its default addressing_style is auto.
The API page does not say which client mistakes produce PermanentRedirect. It states the instruction to use the specified endpoint. The link between that instruction and a wrong Region is our reading, supported by the CLI page above and by the head-bucket page, which says you "will receive a response header with the correct bucket location so that you can then make a proper, signed request to the appropriate Regional endpoint".
A related code is listed separately: AuthorizationHeaderMalformed, "The authorization header you provided is invalid.", with HTTP 400 Bad Request. The page gives no more detail on when it appears, so our advice is to use the same Region check for it.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| The client's Region or endpoint is not the bucket's Region | PermanentRedirect on every request to that bucket |
head-bucket shows a BucketRegion that differs from the configured Region |
| Path-style addressing with a Region that does not match | Fails only with addressing_style = path |
~/.aws/config has addressing_style = path and a different Region |
| A hand-typed endpoint or custom hostname points to another Region | Fails in one tool; the CLI with the bucket's Region may succeed | The tool's endpoint field shows another Region code |
| A legacy global endpoint used for a bucket in a newer Region | HTTP 400 Bad Request rather than 301 | The User Guide: for Regions launched after 20 March 2019 the DNS server returns 400 |
Prove the cause before changing anything
All commands read only.
- Show the Region the CLI uses and where it comes from. The manual says the command shows "where the configuration value was retrieved".
aws configure list
A good result shows the Region you expect. The type and location columns name the source of each value; the manual's example shows the Region coming from an environment variable, AWS_DEFAULT_REGION.
- Ask S3 where the bucket is. The manual says the call returns the bucket's Region "regardless of the permissions on the bucket", and its example output has a
BucketRegionfield.
aws s3api head-bucket --bucket backup-bucket-example
A good result prints JSON with BucketRegion, for example ap-southeast-2. A 400, 403 or 404 error with no message body means the bucket does not exist or you have no permission to access it. The manual says the cause cannot be told from these status codes, and gives "A client error (404) occurred when calling the HeadBucket operation: Not Found" as its example.
- Repeat with the Region named. The manual says
--region"Overrides config/env settings".
aws s3api head-bucket --bucket backup-bucket-example --region ap-southeast-2
- Look for an addressing override in the
s3section of the CLI configuration.
cat ~/.aws/config
The manual says the addressing_style values are path, virtual and auto, with auto as the default.
- For a backup tool, read the Region and endpoint fields of the failing job. Compare them with
BucketRegionfrom step 2.
The get-bucket-location call also reports the Region, but its page says "we recommend that you use the HeadBucket operation instead".
Fix
The fix is to bring the client's Region, and its endpoint if one is typed in, into line with the bucket's Region. The bucket itself stays as it is.
AWS CLI
First save the current state:
printenv AWS_DEFAULT_REGION > region-env-before.txt
Risk: the next command sets the default Region for every AWS CLI command started from this shell. A later command that targets a bucket or service in another Region will fail with a wrong-Region error until the variable is changed back.
Set the Region from step 2:
export AWS_DEFAULT_REGION=ap-southeast-2
To undo it: read region-env-before.txt. If it is empty, the variable was not set before, so remove it. If it holds a value, export that value again (replace old-region with it). Run only the one command that applies, then check.
If the file is empty:
unset AWS_DEFAULT_REGION
If the file holds a value:
export AWS_DEFAULT_REGION=old-region
Then check:
aws configure list
Backup tool
First save the current state: copy the job's current Region and endpoint values into a file such as job-endpoint-before.txt, or take a screenshot of the job's settings page.
Risk: the next step edits the Region and endpoint of a backup job. A wrong value stops that job's uploads until it is corrected.
Open the job's settings and set the Region field to the bucket's Region. If the tool also has an endpoint field, set it to the Regional endpoint from the AWS General Reference table, for example s3.ap-southeast-2.amazonaws.com. Save the job and run its connection test.
To undo it: enter the values saved in job-endpoint-before.txt and run the connection test again.
Custom hostname (CNAME)
The User Guide describes naming a bucket after your domain and pointing a DNS alias at S3. It says "The CNAME DNS record should alias your domain name to the appropriate virtual hosted–style hostname", and gives the example images.example.com.s3.us-east-1.amazonaws.com for a bucket in US East (N. Virginia). The Region code is part of that target name. If the alias target carries a different Region code from the bucket's, requests reach the wrong Regional endpoint; that conclusion is our reading of the page. The page also says "the CNAME DNS record must be defined exactly as shown in the preceding example", and that the procedure for editing records depends on your DNS provider.
The page gives no DNS commands. Editing a live record is a change to name resolution for every client, so it belongs with the DNS provider's own change procedure.
Legacy global endpoint
The User Guide explains that the legacy global endpoint sends requests to US East (N. Virginia) by default. For a bucket in a Region launched before 20 March 2019, S3 updates the DNS record, which "might take time"; in the meantime the request goes to US East (N. Virginia), and S3 then redirects it with "an HTTP 307 Temporary Redirect to the correct Region". That is a different code from PermanentRedirect: the API page lists TemporaryRedirect, "You are being redirected to the bucket while DNS updates." For a bucket in a Region launched after that date, the DNS server "returns an HTTP 400 Bad Request error instead". A client that uses the global endpoint for such a bucket needs the Regional endpoint instead.
Addressing style
If the CLI configuration sets addressing_style = path, the page says the configured Region must match the bucket's Region. Once the Region is corrected, that condition is met. Leave auto unless you have a reason to change it.
Example (illustrative): the nightly job on fs01 for backup-bucket-example fails with PermanentRedirect. aws configure list shows the Region us-east-1, taken from the tool's profile. aws s3api head-bucket --bucket backup-bucket-example prints a BucketRegion of ap-southeast-2. The administrator changes the job's Region to ap-southeast-2 and its endpoint to s3.ap-southeast-2.amazonaws.com. The connection test passes and the next night's run completes.
Confirm the fix
aws s3api head-bucket --bucket backup-bucket-examplestill prints the sameBucketRegion, and the configured Region equals it.- The job's connection test passes.
- The next scheduled run lists and uploads without a redirect or authorization-header error.
What to watch afterwards
- Record each bucket's Region next to the job that uses it.
- When a new bucket is created for an existing job, check its Region before the first run.
- Signing is separate from addressing: if the next error is a signature error, see S3 SignatureDoesNotMatch: "The request signature we calculated does not match the signature you provided".
- To prove that delivered data is complete, see Verify a Backup Delivered to S3 or SFTP Before Recovery.
Read next
Related articles you may want next.
- CloudS3 SignatureDoesNotMatch: "The request signature we calculated does not match the signature you provided"S3 403 SignatureDoesNotMatch? Test the key pair with the AWS CLI, then check the secret key, session token, proxy and signing method.Read article
- CloudS3 403 Access Denied: following policy evaluation across bucket, IAM, KMS and SCPRead the error, identify the caller, then follow AWS policy evaluation through bucket policy, IAM, organisation policies, endpoints and KMS.Read article
- Backup & RecoveryVerify a Backup Delivered to S3 or SFTP Before RecoveryCheck delivered backup identity, completeness and integrity, then rehearse extraction and recovery using independently available credentials.Read article
Risks and limits
- These commands have not been run or lab-tested.
- AWS's pages show no date. Region lists and endpoints change; check the current General Reference page.
- AWS's API page does not say which client mistakes cause
PermanentRedirectorAuthorizationHeaderMalformed. - S3-compatible services from other vendors have their own endpoints and messages. The pages here describe Amazon S3 only.
- Access denied is a different error with a different cause; see S3 403 Access Denied: following policy evaluation across bucket, IAM, KMS and SCP.
Sources
- Error — Amazon S3 API Reference, Amazon Web Services, no date shown, accessed 2 December 2026
- Virtual hosting of general purpose buckets — Amazon S3 User Guide, Amazon Web Services, no date shown, accessed 2 December 2026
- Amazon Simple Storage Service endpoints and quotas — AWS General Reference, Amazon Web Services, no date shown, accessed 2 December 2026
- AWS CLI S3 Configuration — AWS CLI 2.43.0 Command Reference, Amazon Web Services, no date shown, accessed 2 December 2026
- head-bucket — AWS CLI 2.43.0 Command Reference (aws s3api), Amazon Web Services, no date shown, accessed 2 December 2026
- get-bucket-location — AWS CLI 2.43.0 Command Reference (aws s3api), Amazon Web Services, no date shown, accessed 2 December 2026
- list — AWS CLI 2.43.0 Command Reference (aws configure), Amazon Web Services, no date shown, accessed 2 December 2026
This article was originally published on .