Unzipped size must be smaller than 262144000 bytes ☁️ AWS

Lambda: Unzipped size must be smaller than 262144000 bytes

The function code plus layers exceed Lambda’s 250 MB unzipped limit for zip deployments.

Seen on: AWS

Meaning

Heavy dependencies (pandas, numpy, torch, Chromium, the AWS SDK bundled twice) blow past the limit. Container image functions allow up to 10 GB.

Common causes

  • Large dependencies (ML/data libraries, headless browsers)
  • Dev dependencies/tests/docs bundled
  • Same library in both function and layer

⚡ Quick fix

  1. Deploy as a container image (10 GB)
  2. Strip dev dependencies and caches; bundle/tree-shake (esbuild)
  3. Move shared libs to a layer without duplicates

Detailed fix by platform

AWS CLI

  1. bash
    du -sh package/* | sort -h | tail
    # container image function
    aws lambda create-function --function-name fn --package-type Image --code ImageUri=123456789012.dkr.ecr.eu-west-1.amazonaws.com/fn:1 --role arn:aws:iam::123456789012:role/fn-role

How to diagnose

  1. Size — du of unzipped package + layers
  2. Contents — Biggest folders

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