# Unzipped size must be smaller than 262144000 bytes

AWS error fixes · Updated 16 November 2026

**Short answer:** The function's code plus all its layers would take more than 250 MB (262,144,000 bytes) once unzipped, which is the hard limit for zip-based functions. Layers don't get around it because they count toward the same total. Trim the package (remove bundled SDKs, tests and build artefacts), or switch to a container image, which can be up to 10 GB.

## What the error means

```
An error occurred (InvalidParameterValueException) when calling the UpdateFunctionCode operation:
Unzipped size must be smaller than 262144000 bytes
```

Lambda checks the extracted size of the deployment package and every attached layer together. Your zip can be well under 50 MB and still fail, since compression ratios for Python and Node.js dependencies are often five to ten times. Data science libraries are the usual culprits: `numpy`, `pandas`, `scipy`, `pyarrow` and machine learning frameworks are each tens to hundreds of megabytes.

## Measure what's taking the space

```
mkdir /tmp/pkg && unzip -q function.zip -d /tmp/pkg
du -sh /tmp/pkg
du -sh /tmp/pkg/* | sort -h | tail -15
```

Don't forget layers. List them and their sizes for the function:

```
aws lambda get-function-configuration --function-name my-function \
  --query 'Layers[].[Arn,CodeSize]' --output table
```

`CodeSize` there is the zipped size; download and extract a layer the same way to see its real footprint.

## Ways to shrink it

| Change | Typical saving |
|---|---|
| Don't bundle `boto3`/`botocore` (Python) or the AWS SDK v3 (Node.js) unless you need a specific version; the runtime includes them | Tens of MB |
| Node.js: bundle with esbuild instead of shipping `node_modules`; at minimum `npm ci --omit=dev` | Often most of the package |
| Remove tests, docs, type stubs and `__pycache__` directories from installed packages | 10–30% |
| Strip debug symbols from compiled `.so` files (`strip`) | Large for scientific packages |
| Replace heavy libraries with lighter ones (for example `pandas` only for one CSV read) | Hundreds of MB |

A cleanup pass for a Python package directory before zipping:

```
find package -type d \( -name '__pycache__' -o -name 'tests' \) -prune -exec rm -rf {} +
find package -name '*.so' -exec strip --strip-unneeded {} + 2>/dev/null
rm -rf package/boto3 package/botocore
```

Run your tests against the slimmed package; removing a directory a library needs at runtime turns this error into [ImportModuleError](https://cloudconsole.dev/errors/lambda-runtime-importmoduleerror).

## When to move to a container image

If the dependencies are legitimately large, such as ML models or full scientific stacks, a container image is the supported route: images can be up to 10 GB and use the same Lambda features. Build for the function's architecture, push to ECR and deploy with `update-function-code --image-uri`; see [InvalidEntrypoint](https://cloudconsole.dev/errors/lambda-runtime-invalidentrypoint) for the common build pitfalls. Large model files can also be loaded at start-up from EFS, or downloaded to `/tmp` (configurable up to 10 GB of ephemeral storage), although that adds to cold-start time.

Whichever route you take, add a size check to the build so the pipeline fails with a clear message before it reaches Lambda, for example by comparing the output of `du -sb` on the extracted package against the limit.

## Questions

### What is the Lambda deployment package size limit?

250 MB unzipped for code plus all layers, and 50 MB zipped for direct uploads. Container images can be up to 10 GB.

### Do Lambda layers increase the size limit?

No. Layers are counted together with the function code against the same 250 MB unzipped limit.

### How do I include large Python libraries in Lambda?

Slim them where you can, then switch to a container image if they still don't fit. EFS is an option for very large data files or models.

## When this happens away from your desk

Package size errors block a deploy rather than break live traffic. CloudConsole, a phone app for AWS, is built to show function alarms on your phone so you can confirm the running version is still healthy while the build is fixed.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Lambda quotas](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)
- [Create a Lambda function using a container image](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html)

## Related

- [RequestEntityTooLargeException: Request must be smaller than 6291456 bytes](https://cloudconsole.dev/errors/lambda-requestentitytoolarge)
- [CodeStorageExceededException: Code storage limit exceeded](https://cloudconsole.dev/errors/lambda-codestorageexceeded)
- [Runtime.ImportModuleError: Unable to import module](https://cloudconsole.dev/errors/lambda-runtime-importmoduleerror)
- [aws lambda update-function-code](https://cloudconsole.dev/cli/lambda-update-function-code)
- [aws lambda publish-layer-version](https://cloudconsole.dev/cli/lambda-publish-layer-version)
- [Lambda was unable to configure your environment variables: exceeded the 4KB limit](https://cloudconsole.dev/errors/lambda-environment-variables-exceeded-4kb)

---

Source: https://cloudconsole.dev/errors/lambda-unzipped-size-too-large

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
