Troubleshoot deployment issues in Lambda - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Troubleshoot deployment issues in Lambda

When you update your function, Lambda deploys the change by launching new instances of the function with the updated code or settings. Deployment errors prevent the new version from being used and can arise from issues with your deployment package, code, permissions, or tools.

When you deploy updates to your function directly with the Lambda API or with a client such as the Amazon CLI, you can see errors from Lambda directly in the output. If you use services like Amazon CloudFormation, Amazon CodeDeploy, or Amazon CodePipeline, look for the response from Lambda in the logs or event stream for that service.

The following topics provide troubleshooting advice for errors and issues that you might encounter when using the Lambda API, console, or tools. If you find an issue that is not listed here, you can use the Feedback button on this page to report it.

For more troubleshooting advice and answers to common support questions, visit the Amazon Knowledge Center.

For more information about debugging and troubleshooting Lambda applications, see Debugging in Serverless Land.

General: Permission is denied / Cannot load such file

Error: EACCES: permission denied, open '/var/task/index.js'

Error: cannot load such file -- function

Error: [Errno 13] Permission denied: '/var/task/'

The Lambda runtime needs permission to read the files in your deployment package. In Linux permissions octal notation, Lambda needs 644 permissions for non-executable files (rw-r--r--) and 755 permissions (rwxr-xr-x) for directories and executable files.

In Linux and MacOS, use the chmod command to change file permissions on files and directories in your deployment package. For example, to give an executable file the correct permissions, run the following command.

chmod 755 <filepath>

To change file permissions in Windows, see Set, View, Change, or Remove Permissions on an Object in the Microsoft Windows documentation.

General: Error occurs when calling the UpdateFunctionCode

Error: An error occurred (RequestEntityTooLargeException) when calling the UpdateFunctionCode operation

When you upload a deployment package or layer archive directly to Lambda, the size of the ZIP file is limited to 50 MB. To upload a larger file, store it in Amazon S3 and use the S3Bucket and S3Key parameters.


When you upload a file directly with the Amazon CLI, Amazon SDK, or otherwise, the binary ZIP file is converted to base64, which increases its size by about 30%. To allow for this, and the size of other parameters in the request, the actual request size limit that Lambda applies is larger. Due to this, the 50 MB limit is approximate.

Amazon S3: Error Code PermanentRedirect.

Error: Error occurred while GetObject. S3 Error Code: PermanentRedirect. S3 Error Message: The bucket is in this region: us-east-2. Please use this region to retry the request

When you upload a function's deployment package from an Amazon S3 bucket, the bucket must be in the same Region as the function. This issue can occur when you specify an Amazon S3 object in a call to UpdateFunctionCode, or use the package and deploy commands in the Amazon CLI or Amazon SAM CLI. Create a deployment artifact bucket for each Region where you develop applications.

General: Cannot find, cannot load, unable to import, class not found, no such file or directory

Error: Cannot find module 'function'

Error: cannot load such file -- function

Error: Unable to import module 'function'

Error: Class not found: function.Handler

Error: fork/exec /var/task/function: no such file or directory

Error: Unable to load type 'Function.Handler' from assembly 'Function'.

The name of the file or class in your function's handler configuration doesn't match your code. See the following section for more information.

General: Undefined method handler

Error: index.handler is undefined or not exported

Error: Handler 'handler' missing on module 'function'

Error: undefined method `handler' for #<LambdaHandler:0x000055b76ccebf98>

Error: No public method named handleRequest with appropriate method signature found on class function.Handler

Error: Unable to find method 'handleRequest' in type 'Function.Handler' from assembly 'Function'

The name of the handler method in your function's handler configuration doesn't match your code. Each runtime defines a naming convention for handlers, such as filename.methodname. The handler is the method in your function's code that the runtime runs when your function is invoked.

For some languages, Lambda provides a library with an interface that expects a handler method to have a specific name. For details about handler naming for each language, see the following topics.

Lambda: Layer conversion failed

Error: Lambda layer conversion failed. For advice on resolving this issue, see the Troubleshoot deployment issues in Lambda page in the Lambda User Guide.

When you configure a Lambda function with a layer, Lambda merges the layer with your function code. If this process fails to complete, Lambda returns this error. If you encounter this error, take the following steps:

  • Delete any unused files from your layer

  • Delete any symbolic links in your layer

  • Rename any files that have the same name as a directory in any of your function's layers

Lambda: InvalidParameterValueException or RequestEntityTooLargeException

Error: InvalidParameterValueException: Lambda was unable to configure your environment variables because the environment variables you have provided exceeded the 4KB limit. String measured: {"A1":"uSFeY5cyPiPn7AtnX5BsM...

Error: RequestEntityTooLargeException: Request must be smaller than 5120 bytes for the UpdateFunctionConfiguration operation

The maximum size of the variables object that is stored in the function's configuration must not exceed 4096 bytes. This includes key names, values, quotes, commas, and brackets. The total size of the HTTP request body is also limited.

{ "FunctionName": "my-function", "FunctionArn": "arn:aws-cn:lambda:us-east-2:123456789012:function:my-function", "Runtime": "nodejs20.x", "Role": "arn:aws-cn:iam::123456789012:role/lambda-role", "Environment": { "Variables": { "BUCKET": "DOC-EXAMPLE-BUCKET", "KEY": "file.txt" } }, ... }

In this example, the object is 39 characters and takes up 39 bytes when it's stored (without white space) as the string {"BUCKET":"DOC-EXAMPLE-BUCKET","KEY":"file.txt"}. Standard ASCII characters in environment variable values use one byte each. Extended ASCII and Unicode characters can use between 2 bytes and 4 bytes per character.

Lambda: InvalidParameterValueException

Error: InvalidParameterValueException: Lambda was unable to configure your environment variables because the environment variables you have provided contains reserved keys that are currently not supported for modification.

Lambda reserves some environment variable keys for internal use. For example, AWS_REGION is used by the runtime to determine the current Region and cannot be overridden. Other variables, like PATH, are used by the runtime but can be extended in your function configuration. For a full list, see Defined runtime environment variables.

Lambda: Concurrency and memory quotas

Error: Specified ConcurrentExecutions for function decreases account's UnreservedConcurrentExecution below its minimum value

Error: 'MemorySize' value failed to satisfy constraint: Member must have value less than or equal to 3008

These errors occur when you exceed the concurrency or memory quotas for your account. New Amazon accounts have reduced concurrency and memory quotas. To resolve errors related to concurrency, you can request a quota increase. You cannot request memory quota increases.

  • Concurrency: You might get an error if you try to create a function using reserved or provisioned concurrency, or if your per-function concurrency request (PutFunctionConcurrency) exceeds your account's concurrency quota.

  • Memory: Errors occur if the amount of memory allocated to the function exceeds your account's memory quota.