RequestEntityTooLargeException ☁️ AWS

Lambda: Request must be smaller than 6291456 bytes for the InvokeFunction operation (RequestEntityTooLargeException)

The event payload (or response) is over Lambda’s 6 MB synchronous limit (256 KB for async invocations).

Seen on: AWS

Meaning

Payload limits apply to the request and the response. API Gateway uploads of files, large JSON batches, or functions returning big responses hit it. Put large data in S3 and pass a reference instead.

Common causes

  • Uploading files through API Gateway → Lambda
  • Large batch payloads
  • Function response over 6 MB
  • Async invoke (event) over 256 KB

⚡ Quick fix

  1. Upload to S3 with a presigned URL and pass the key
  2. Paginate or compress responses
  3. Split batches

Detailed fix by platform

Node.js

  1. javascript
    const url = await getSignedUrl(s3, new PutObjectCommand({ Bucket, Key }), { expiresIn: 300 });
    // client uploads directly to S3, then calls the API with { key }

How to diagnose

  1. Size — Request/response bytes
  2. Invocation — Sync or async?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 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.