A browser upload to S3 fails: `has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource`.
IntermediateTroubleshootingS3, EBS and EFS
Answer
Likely causes → The bucket has no CORS configuration, or it does not list the origin, method (PUT/POST) or headers the browser sends in the preflight. Presigned PUTs with custom headers such as Content-Type need AllowedHeaders.
Diagnose →
aws s3api get-bucket-cors --bucket uploads
curl -i -X OPTIONS "https://uploads.s3.amazonaws.com/test.txt" \
-H 'Origin: https://app.example.com' -H 'Access-Control-Request-Method: PUT'
Fix →
aws s3api put-bucket-cors --bucket uploads --cors-configuration '{
"CORSRules":[{"AllowedOrigins":["https://app.example.com"],"AllowedMethods":["PUT","GET"],
"AllowedHeaders":["*"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]}'
If CloudFront is in front, forward the Origin header in the origin request policy.
Prevent → Keep the CORS config in IaC with explicit origins per environment. Never use * together with credentials.
More on S3, EBS and EFS
`BucketAlreadyExists: The requested bucket name is not available. The bucket namespace is shared by all users of the system.`Beginner`PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint.`BeginnerA partner account uploads objects into your bucket, but your own admins get `403 Forbidden` reading them.Intermediate`aws s3 cp` gets `An error occurred (AccessDenied) when calling the GetObject operation` but the IAM policy allows `s3:GetObject` and the bucket policy is fine.IntermediateAn S3 static website endpoint returns `403 Forbidden` with `Code: AccessDenied`.IntermediateHigh-throughput writes get `503 SlowDown: Please reduce your request rate.`Intermediate