AWS

NoSuchBucket - No Such Bucket

Getting a **NoSuchBucket** error means the S3 bucket you're trying to access doesn't exist in your AWS account, or you don't have permission to see it—the bucket might have been deleted, the name is misspelled, or it's in a different region. This client-side error (4xx) happens when AWS can't find the bucket. Most common when bucket names have typos, but also appears when buckets were deleted, buckets are in different regions, IAM policies don't grant ListBucket permission, or you're accessing a bucket from another account without proper permissions.

#Common Causes

  • Identity: IAM policy missing s3:ListBucket permission. Bucket policy denies access. Cross-account access not configured. IAM user/role can't see bucket.
  • Network: Bucket in different region than expected. VPC endpoint doesn't route to correct region. Cross-region access issues.
  • Limits: Bucket was deleted. Bucket name typo. Bucket doesn't exist in your account. Bucket in different AWS account.

Solutions

  1. 1Step 1: Diagnose - List all buckets in your account: aws s3 ls. Check if bucket name appears in the list. Verify spelling of bucket name.
  2. 2Step 2: Diagnose - Check bucket in specific region: aws s3api head-bucket --bucket BUCKET_NAME --region REGION. Try different regions if bucket not found.
  3. 3Step 3: Diagnose - Verify IAM permissions: aws iam simulate-principal-policy --policy-source-arn YOUR_ARN --action-names s3:ListBucket --resource-arns arn:aws:s3:::BUCKET_NAME. Check if s3:ListBucket is allowed.
  4. 4Step 4: Fix - Check bucket region: aws s3api get-bucket-location --bucket BUCKET_NAME. Use correct region in requests: aws s3 ls s3://BUCKET_NAME --region REGION.
  5. 5Step 5: Fix - Verify bucket exists: aws s3api head-bucket --bucket BUCKET_NAME. If access denied, check IAM policies. If 404, bucket doesn't exist or wrong account.

</>Code Examples

List Buckets and Check Existence
1#!/bin/bash
2# List all buckets in your account
3echo "=== Your Buckets ==="
4aws s3 ls
5
6# Check if specific bucket exists
7BUCKET_NAME="my-bucket-name"
8echo "\n=== Checking Bucket: ${BUCKET_NAME} ==="
9aws s3api head-bucket --bucket ${BUCKET_NAME} 2>&1
10if [ $? -eq 0 ]; then
11  echo "✓ Bucket exists"
12else
13  echo "✗ Bucket not found or access denied"
14  echo "Error details:"
15  aws s3api head-bucket --bucket ${BUCKET_NAME} 2>&1
16fi
17
18# Get bucket location (region)
19echo "\n=== Bucket Region ==="
20aws s3api get-bucket-location --bucket ${BUCKET_NAME} 2>&1 || echo "Cannot determine region (bucket may not exist)"
21
22# List bucket contents (requires s3:ListBucket permission)
23echo "\n=== Bucket Contents ==="
24aws s3 ls s3://${BUCKET_NAME}/ 2>&1 || echo "Cannot list contents (check permissions or bucket existence)"
Check IAM Permissions for S3 Bucket
1#!/bin/bash
2# Check your current identity
3echo "=== Current Identity ==="
4IDENTITY_ARN=$(aws sts get-caller-identity --query Arn --output text)
5echo "Identity: ${IDENTITY_ARN}"
6
7# Simulate s3:ListBucket permission
8BUCKET_NAME="my-bucket-name"
9echo "\n=== Simulating s3:ListBucket Permission ==="
10aws iam simulate-principal-policy \
11  --policy-source-arn ${IDENTITY_ARN} \
12  --action-names s3:ListBucket \
13  --resource-arns "arn:aws:s3:::${BUCKET_NAME}" \
14  --query 'EvaluationResults[0].[EvalDecision,EvalResourceName]' \
15  --output table
16
17# Check bucket policy
18echo "\n=== Bucket Policy ==="
19aws s3api get-bucket-policy --bucket ${BUCKET_NAME} 2>&1 || echo "No bucket policy or access denied"
20
21# Check bucket ACL
22echo "\n=== Bucket ACL ==="
23aws s3api get-bucket-acl --bucket ${BUCKET_NAME} 2>&1 || echo "Cannot read ACL (check permissions)"
Check Bucket in Different Regions
1#!/bin/bash
2BUCKET_NAME="my-bucket-name"
3
4# Common AWS regions
5REGIONS=("us-east-1" "us-west-2" "eu-west-1" "ap-southeast-1")
6
7echo "=== Checking Bucket in Different Regions ==="
8for REGION in "${REGIONS[@]}"; do
9  echo "\nChecking region: ${REGION}"
10  aws s3api head-bucket \
11    --bucket ${BUCKET_NAME} \
12    --region ${REGION} 2>&1 | head -1
13done
14
15# If bucket found, use correct region in operations
16echo "\n=== Using Correct Region ==="
17CORRECT_REGION="us-east-1"  # Replace with actual region
18aws s3 ls s3://${BUCKET_NAME}/ --region ${CORRECT_REGION}

Related Errors

Provider Information

This error code is specific to AWS services. For more information, refer to the official AWS documentation.

NoSuchBucket - No Such Bucket | AWS Error Reference | Error Code Reference