Get Hands-on with Amazon EKS - Workshop Event Series
Whether you're taking your first steps with Kubernetes or you're an experienced practitioner looking to sharpen your skills, our Amazon EKS workshop series delivers practical, real-world experience that moves you forward. Learn directly from AWS solutions architects and EKS specialists through hands-on sessions designed to build your confidence with Kubernetes. Register now and start building with Amazon EKS!
How do I troubleshoot Lambda function "runtime exited" errors?
2 minute read
0
My AWS Lambda function returned a "Runtime exited with error: exit status 129" error.
Resolution
Follow these best practices to review the Lambda function code, identify the root cause, and troubleshoot the runtime error:
Check the function code for exit codes that explicitly calls syntax such as process.exit(0), exit(), quit(), os.Exit(), and Environment.Exit(). If the function code contains any of these exit codes, then either remove them or replace them with a valid return statement.
Review the Amazon CloudWatch Logs for the Lambda function and confirm the function's memory. Lambda allocates CPU power in proportion to the amount of memory configured. If the memory consumption reached the configured limit. then you might have to increase the amount of memory. You can configure the amount of memory allocated to a Lambda function between 128 MB and 10,240 MB. You can also optimize the code to reduce the amount of resources consumed. For more information, see Determining the appropriate memory setting for a Lambda function.
If the function connects to backend databases, then too many connections might occur. To avoid unnecessary connections, initialize database connections outside of the function handler. Subsequent Lambda function invocation requests can reuse these database connections. For more information, see Best practices for working with AWS Lambda functions.
Attempts to reuse an idle connection when you invoke a Lambda function results in a connection error. To maintain a persistent connection, use the keep-alive directive associated with your runtime. For more information, see Reusing connections with keep-alive in Node.js.