Skip to content

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.
  • Check to see if the Lambda function has "out of memory" errors because of the file descriptors and threads limit of 1,024. Turn on Lambda Insights enhanced monitoring on the function. You can use a specialized query syntax to search and analyze log data for memory usage metrics. For example, you can monitor the fd_use metric. The metrics are stored in the log group name /aws/lambda-insights. For more information, see Metrics collected by Lambda Insights.
AWS OFFICIALUpdated 3 years ago