NoSuchKey ☁️ AWS

AWS S3: NoSuchKey / NoSuchBucket — The specified key/bucket does not exist

S3 found no object at that key (or no bucket with that name in the region/account you’re calling).

Seen on: AWS JavaScript

Meaning

Keys are exact strings — case, leading slashes and URL encoding all matter. Note: without s3:ListBucket permission, S3 returns AccessDenied (403) instead of NoSuchKey for missing objects.

Common causes

  • Wrong key: leading /, case, or missing folder prefix
  • URL-encoded characters (spaces → +/%20) not decoded
  • Object not uploaded yet / deleted / lifecycle-expired
  • Bucket name typo or wrong account/region
  • Static website hosting without index document

⚡ Quick fix

  1. List what exists: aws s3 ls s3://bucket/prefix/
  2. Strip leading slashes and decode keys from events (decodeURIComponent(key.replace(/\+/g, " ")))
  3. Verify bucket name and account

Detailed fix by platform

AWS

  1. S3 event keys are URL-encoded:
    javascript
    export const handler = async (event) => {
      const raw = event.Records[0].s3.object.key;
      const key = decodeURIComponent(raw.replace(/\+/g, ' '));   // "my+file.pdf" → "my file.pdf"
    };

How to diagnose

  1. Key — Exact key string (print it)
  2. Listing — What does aws s3 ls show under the prefix?
  3. Bucket — Right bucket/account/region?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.