---
title: "Lambda fails right after a deploy: import, handler or init timeout | Proofline"
description: "When invocations fail right after a Lambda deploy, read the runtime's error type and compare the new version's Handler and package with the old one's."
url: https://proofline.sh/learn/lambda-init-errors-after-deploy/
---

[Learning center](/learn/)

# Lambda fails right after a deploy: import, handler or init timeout

When invocations fail right after a Lambda deploy, read the runtime's error type and compare the new version's Handler and package with the old one's. The error type names the step that failed; the comparison tells you whether the package or the handler setting changed.

Deployment failures The Proofline team November 22, 2026 6 min read

## The signature and its nearby causes

The deploy succeeded: `LastUpdateStatus` is `Successful`, and the alias points at the new version. Then every invocation that reaches the new version fails, often before your handler logs anything. The failure happens during the init phase, when Lambda starts the runtime, loads your code and runs code outside the handler. Three causes share that signature:

-   **Packaging.** The module the handler names, or something it imports, is not in the package or cannot load on this runtime.
-   **Handler setting.** The package is fine, but the `Handler` setting names a file or function that does not exist in it, or a container image's entry point is wrong.
-   **Init duration.** The code loads, but initialization takes longer than Lambda allows.

[Lambda execution environment lifecycle](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html) · [Troubleshoot invocation issues](https://docs.aws.amazon.com/lambda/latest/dg/troubleshooting-invocation.html)

If the update itself failed instead, `LastUpdateStatus` is `Failed` and the old code is still running; see [the reason code guide](/learn/lambda-update-failed-reason-codes/).

## Read the error type

Use a read-only profile and replace the uppercase placeholders. Lambda writes to `/aws/lambda/FUNCTION_NAME` by default. This Logs Insights query over the minutes after the deploy finds runtime error types and init reports. [LoggingConfig](https://docs.aws.amazon.com/lambda/latest/api/API_LoggingConfig.html)

```
fields @timestamp, @logStream, @message
| filter @message like /Runtime\.|INIT_REPORT|Init Duration|Sandbox\.Timedout/
| sort @timestamp desc
| limit 50
```

| What the log or response shows | Step that failed | Most likely cause |
| --- | --- | --- |
| `Runtime.ImportModuleError`, with `Unable to import module` (Python) or `Cannot find module` (Node.js) | Loading the handler's module | Packaging, or a handler setting that names a missing file |
| An error saying the handler function was not found or not exported | Finding the function in a module that loaded | Handler setting |
| `Runtime.InvalidEntrypoint` | Starting a custom runtime or container image | No executable `bootstrap` at the package root, or a wrong image entry point |
| An `INIT_REPORT` line with `Status: timeout` | Finishing init in time | Init duration |
| `Sandbox.Timedout` with no init timeout in the same log stream | Running the handler | The function timeout or a slow dependency, not init |

`Sandbox.Timedout` alone does not place the timeout in init, because a handler that runs past the function timeout reports it too. Read it as an init failure only beside an `INIT_REPORT` timeout for the same environment. The import error names come from AWS's Knowledge Center articles for Python and Node.js. AWS's guides found for this page do not name an error type for a handler function that is missing from a module that loaded, so read the message for the function name. For `Runtime.InvalidEntrypoint`, the troubleshooting page describes a runtime that could not find a valid `bootstrap` in `/var/task` or `/opt`, and a separate Knowledge Center article covers a misconfigured entry point in a container image. Wording inside the messages varies by runtime, so key on the error type. [Python import errors](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-import-module-error-python/) · [Node.js import errors](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-import-module-error-nodejs/) · [InvalidEntrypoint in images](https://aws.amazon.com/premiumsupport/knowledge-center/lambda-docker-image-error/)

## Compare the two versions' settings

An import error can come from either a broken package or a handler that points at the wrong file, and the error type alone does not say which. Compare the configuration of the version that worked with the one that fails. [FunctionConfiguration](https://docs.aws.amazon.com/lambda/latest/api/API_FunctionConfiguration.html)

```
for v in PREVIOUS_VERSION NEW_VERSION; do
  aws lambda get-function-configuration \
    --profile PROFILE --region REGION --function-name FUNCTION_NAME --qualifier "$v" \
    --query '{version:Version,handler:Handler,runtime:Runtime,package:PackageType,sha:CodeSha256,size:CodeSize,layers:Layers[].Arn,timeout:Timeout,memory:MemorySize,architectures:Architectures,image:ImageConfigResponse.ImageConfig}' \
    --output json --no-cli-pager
done
```

| What differs between the versions | Reading |
| --- | --- |
| `handler` | The handler setting changed. Check the new value against the file and function names in the package; each runtime has its own convention, such as `filename.methodname` |
| `sha` and `size` only | The package changed under the same settings. List the new package's contents and compare its layout and dependencies with the old one |
| `runtime`, `layers` or `architectures` | The package may be fine but built for another runtime version or CPU architecture, or it relied on a layer that is gone |
| `image` (entry point, command, working directory) | A container image override changed |
| Nothing but `sha` and init now takes longer | Read init duration next |

The code in a package must be compatible with the function's instruction set architecture, `x86_64` or `arm64`. [Handler naming](https://docs.aws.amazon.com/lambda/latest/dg/troubleshooting-deployment.html) · [UpdateFunctionCode](https://docs.aws.amazon.com/lambda/latest/api/API_UpdateFunctionCode.html)

## When init runs out of time

The init phase is limited to 10 seconds. If the runtime and extensions are not ready within that time, Lambda retries init at the first invocation, this time with the function's configured timeout, and AWS recommends against depending on that retry. A timeout appears in the log as an `INIT_REPORT` line, in AWS's example `INIT_REPORT Init Duration: 1236.04 ms Phase: init Status: timeout`. [Execution environment lifecycle](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html)

So an init timeout after a deploy points at one of two changes: the new code does more work at startup, such as loading a larger library or opening connections, or the function's `Timeout` is too short for init and the handler together on that retry. AWS's troubleshooting page suggests raising the function timeout so that both phases fit. That helps only if init finishes within the new timeout; if the release added startup work, reduce it, then read `Init Duration` on the next cold start. [Troubleshoot invocation issues](https://docs.aws.amazon.com/lambda/latest/dg/troubleshooting-invocation.html)

The operator guide notes that the 10-second limit does not apply to functions using provisioned concurrency, SnapStart or Lambda Managed Instances. For Lambda Managed Instances, AWS documents init failures as `LastUpdateStatusReasonCode` values that begin with `FunctionError.`, reported on the update rather than on an invocation. [Static initialization](https://docs.aws.amazon.com/lambda/latest/operatorguide/static-initialization.html) · [Managed Instances troubleshooting](https://docs.aws.amazon.com/lambda/latest/dg/lambda-managed-instances-troubleshooting.html)

## An illustrative example: two failed releases

These records are fictional. The function `checkout-api` runs Python on version 57, and the alias `live` moves to version 58 at 14:00.

In the first release, every invocation of version 58 returns `Runtime.ImportModuleError` with `No module named 'stripe_client'`. Comparing versions 57 and 58 shows the same `Handler`, `Runtime` and `Layers`, a new `CodeSha256`, and a `CodeSize` 3 MB smaller. The build step that vendored dependencies into the package was skipped. Rebuild the package; the handler setting is fine.

In the second release, the error says the handler function was not found. The comparison shows `Handler` changed from `app.handler` to `app.checkout` in the infrastructure template, while `app.py` still defines its entry function as `handler`. The module loaded; the function name is wrong. The package is fine. Set `Handler` back to `app.handler`, or rename the function to match.

## Where the error type stops helping

-   Init runs when Lambda creates an execution environment. With a weighted alias or a canary, only the share of traffic routed to the new version fails, so the error rate looks smaller than the defect. In CloudWatch, the `ExecutedVersion` dimension separates error rates for the two versions behind a weighted alias. [Viewing Lambda metrics](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-view.html)
-   The `Errors` metric counts runtime errors, such as timeouts and configuration errors, together with exceptions your code throws, so a rise in `Errors` alone does not separate an init failure from a handler bug. The log does. [Lambda metric types](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html)

For the matching fields in other AWS deployment services, see the [signature table](/learn/aws-deployment-failure-signatures/). If the deployment used CodeDeploy traffic shifting, an alarm on these errors can roll it back; [the canary rollback guide](/learn/lambda-alias-canary-rollback/) shows how to tell the alarm from a traffic hook.

## Questions

### What does Runtime.ImportModuleError mean in Lambda?

The runtime could not load the module your handler names or something that module imports. Check that the package contains the module and its dependencies at the expected path, and that the handler setting names the right file.

### How do I tell a packaging error from a wrong handler setting?

Compare `Handler`, `Runtime`, `Layers` and `CodeSha256` between the version that worked and the one that fails. If only the package hash changed, the package is the suspect; if `Handler` changed, check it against the files in the package.

### How long can Lambda initialization take?

The init phase is limited to 10 seconds. If it does not finish, Lambda retries init at the first invocation within the function's configured timeout. The 10-second limit does not apply with provisioned concurrency, SnapStart or Lambda Managed Instances.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Lambda LastUpdateStatus Failed: sort the reason code](/learn/lambda-update-failed-reason-codes/)
    
    Deployment failures The Proofline team November 22, 2026 6 min read
    
-   ### [Lambda canary rolled back by CodeDeploy: alarm or traffic hook](/learn/lambda-alias-canary-rollback/)
    
    Deployment failures The Proofline team November 22, 2026 7 min read
