CloudConsole

BucketNotEmpty: The bucket you tried to delete is not empty

Updated 17 November 2026 · How we write and check guides

Short answer

S3 only deletes empty buckets, and in a versioned bucket "empty" includes every old object version and delete marker, which aws s3 rm and aws s3 rb --force don't remove. Empty the bucket from the console's Empty button, or delete all versions and delete markers with list-object-versions and delete-objects, then delete the bucket.

On this page, in 5 steps: 1. Why it happens; 2. Unversioned bucket: the quick way; 3. Versioned bucket: delete every…
The diagnosis and fix steps from this page, in the order to try them; commands and details are below.

Why it happens

An error occurred (BucketNotEmpty) when calling the DeleteBucket operation:
The bucket you tried to delete is not empty. You must delete all versions in the bucket.

The common trap: aws s3 ls s3://my-bucket shows nothing, yet deletion still fails. Listing only shows current objects. If versioning is (or ever was) enabled, deleting an object just adds a delete marker and keeps the old versions, and those still count.

Unversioned bucket: the quick way

If versioning was never enabled, this removes all objects and then the bucket. It is irreversible.

aws s3 rb s3://my-bucket --force

Check first:

aws s3api get-bucket-versioning --bucket my-bucket

An empty response means versioning was never turned on. Enabled or Suspended means old versions may exist; use the next section.

Versioned bucket: delete every version

Destructive: this permanently deletes all data in the bucket. Run it with the bucket name double-checked. The loop deletes a batch at a time, staying under the 1,000-key limit of a single DeleteObjects call, until nothing is left:

B=my-bucket
while :; do
  aws s3api list-object-versions --bucket "$B" --max-items 500 --output json \
    --query '{Objects: [Versions, DeleteMarkers][][].{Key: Key, VersionId: VersionId}}' > /tmp/batch.json
  [ "$(jq '.Objects | length' /tmp/batch.json)" -eq 0 ] && break
  aws s3api delete-objects --bucket "$B" --delete file:///tmp/batch.json --query 'length(Errors || `[]`)'
done
aws s3api delete-bucket --bucket "$B"

For buckets with millions of objects this is slow. A cheaper route is a lifecycle rule that expires current versions, permanently deletes noncurrent versions after one day and removes expired delete markers; S3 then empties the bucket in the background (it can take a day or more), after which you delete it. The console's Empty action also handles versions, and works well for small and medium buckets.

When something still blocks deletion

BlockerWhat to do
Object Lock retention or legal holdObjects can't be deleted until retention expires (compliance mode can't be shortened). Plan for it; you can't force it.
Bucket policy denying s3:DeleteObject or s3:DeleteBucketDelete errors show AccessDenied in the Errors list; adjust the policy first
Something keeps writingAccess logs, CloudTrail, Config or an application still delivers objects; stop the writer first
MFA delete enabledPermanently deleting versions requires the root user's MFA

CloudFormation DELETE_FAILED

Stacks fail to delete with The bucket you tried to delete is not empty because CloudFormation doesn't empty buckets. Empty it with the steps above, then retry the stack deletion; or retry while retaining the bucket resource and delete it later. If you want stacks to clean up after themselves in non-production, CDK's autoDeleteObjects option adds a custom resource that empties the bucket on delete.

Questions

How do I delete a non-empty S3 bucket with the AWS CLI?

For an unversioned bucket, aws s3 rb s3://bucket --force. For a versioned one, delete all object versions and delete markers with list-object-versions and delete-objects, then run aws s3api delete-bucket.

Why does my S3 bucket say not empty when it has no objects?

It has old object versions or delete markers from versioning. They don't appear in a normal listing but must be deleted before the bucket can be.

Does aws s3 rb --force delete versions?

No. It removes current objects only, so on a versioned bucket it leaves old versions and delete markers and the bucket delete still fails.

CloudConsole S3 object share sheet on a phone, for following up on BucketNotEmpty away from your desk
When this happens away from your desk

Bucket deletion is rarely urgent, but it is exactly the kind of destructive action that deserves a second look. CloudConsole, a phone app for AWS, is built with production guardrails so viewing resources on a phone doesn't come with a one-tap path to deleting them.

Did it start after a deploy? What changed? on the app’s alarm screen lists the deploys and configuration changes from the hour before the alarm fired.

About the app → · Download on the App Store

Sources