Problem
An S3 request fails with AuthorizationHeaderMalformed and an error detail saying the request used the wrong Region. This guide covers that specific diagnostic; malformed authorization can have other causes.
Check the Bucket Location
Using credentials allowed to inspect the bucket:
aws s3api get-bucket-location --bucket YOUR_BUCKET_NAMEFor this API, a null location means us-east-1. The legacy EU value represents eu-west-1. Do not copy either value directly into a client Region setting.
Fix the Client Configuration
Set the SDK or CLI to the bucket's actual Region. A Python example:
import boto3
s3 = boto3.client("s3", region_name="eu-west-1")
response = s3.head_object(
Bucket="YOUR_BUCKET_NAME",
Key="existing-object.txt",
)
print(response["ResponseMetadata"]["HTTPStatusCode"])Replace the Region, bucket, and key. Use the normal credential provider chain rather than embedding credentials in source code. Review explicit endpoint overrides and environment/profile settings if the application keeps selecting the wrong Region.
Verify
Retry the original operation with the corrected configuration. If the error changes to AccessDenied, investigate permissions separately; correcting signing does not grant access.
For manually signed requests, prefer a supported SDK and follow AWS Signature Version 4 requirements instead of editing an authorization header by hand.