Skip to content

API Gateway proxy integration does not forward Lambda throttling (HTTP 429) to client — needs product support

0

Hi AWS community,

We are using API Gateway REST API with Lambda proxy integration. When our Lambda function throttles due to concurrency limits, it returns HTTP 429 TooManyRequestsException. However, API Gateway converts this into HTTP 500 Internal Server Error for the client and does not forward the original status code or x‑amzn‑ErrorType=TooManyRequestsException header.

Observed Behavior:

  • Lambda logs show 429 and proper error header.
  • API Gateway execution logs show integration failure and method completed with status 500.
  • Client only sees HTTP 500 with no indication of throttling.

Desired Enhancements / Feature Requests:

  1. Allow API Gateway proxy integration to propagate backend Lambda error codes (especially 429) directly to clients, without switching to non‑proxy integration.
  2. Or expose a configuration to map integration failure types (like throttling) to custom HTTP status codes.
  3. Or reliably forward the original error type header so clients can distinguish throttling vs internal failures.

Any inputs on whether others are facing this? Has anyone found a production‑safe workaround without moving off proxy mode?

2 Answers
2

My understanding is: The behavior you are seeing is expected because AWS service-level throttling (due to Concurrency Limits) occurs before your Lambda code is even invoked. Since the Lambda doesn't execute, it cannot return the required JSON object for the Proxy Integration, causing API Gateway to default to a 500 Internal Server Error.

To solve this without leaving Proxy Integration, you should configure Gateway Responses in API Gateway:

  • Gateway Response Types: Specifically, you need to customize the DEFAULT_429 (for API Gateway level throttling) and potentially DEFAULT_5XX (if the integration fails to reach Lambda due to service limits).
  • Implementation: In the API Gateway Console, go to Gateway Responses. You can map these responses to return a 429 status code and manually add the x-amzn-ErrorType: TooManyRequestsException header.
  • This acts as a "catch-all" at the API Gateway level for cases where the Lambda cannot be reached or fails to respond correctly, satisfying your requirement for a production-safe workaround in proxy mode.

This ensures the client receives the correct status code even when your Lambda function never starts.

Look for the following log sequence:

  • Integration Request Error: You will likely see Execution failed due to configuration error or Execution failed due to limit exceeded.
  • Early Exit: If the log shows the execution failing immediately after the "Method Request" stage and before the "Method Response" stage, it confirms that API Gateway is generating the 500 error itself because it couldn't successfully invoke the Lambda.

In these specific scenarios, Gateway Responses (specifically DEFAULT_5XX or THROTTLED) are the only way to intercept and re-map the status code back to a 429 for the client.

EXPERT
answered 2 months ago
  • I’m facing the same issue as the original poster and am hoping for the same solution.

    When I tested your suggestion, it appeared that Lambda’s TooManyRequestsException is mapped to DEFAULT_5XX rather than DEFAULT_429 in API Gateway. As I understand it, if we remap DEFAULT_5XX to 429, the 5XX errors that Lambda returns when it runs normally will also become 429s. Does this mean it’s not possible to set it to 429 only when Lambda returns a 500 and the response header includes x-amzn-ErrorType: TooManyRequestsException?

    I look forward to your response.

1

When using Lambda proxy integration with API Gateway, Lambda is required to return output in a specific format that includes a statusCode property and optionally a headers property. API Gateway will map the Lambda response to an HTTP response based on the statusCode you specify in the Lambda function's return value.

For API Gateway to properly pass error types like throttling (429) to clients in proxy integration mode, your Lambda function must return the error in the correct format. The response should include:

  • A statusCode set to the appropriate HTTP status code (e.g., 429 for throttling)
  • A headers property that can include error type information (e.g., "X-Amzn-ErrorType":"TooManyRequestsException")

If you're seeing a 500 error instead of a 429, this suggests the Lambda function may not be returning the response in the expected proxy integration format. When Lambda itself is being throttled by AWS (due to concurrency limits), this is a service-level throttle that occurs before your function code executes, which may not follow the standard proxy integration response format.

The behavior you're describing—where Lambda throttling results in a 500 error—is likely because the throttling is happening at the Lambda service level rather than being handled within your function code. In proxy integration mode, API Gateway expects a properly formatted response from your Lambda function, but service-level throttles may not provide this format.

To work around this limitation while staying in proxy mode, you would need to implement throttling logic within your Lambda function code itself, allowing you to return a properly formatted 429 response. However, this doesn't address AWS service-level concurrency throttles.

For distinguishing between different error types at the client level, ensure your Lambda function returns responses with appropriate status codes and custom headers when errors occur within your application logic.
Sources
Handle Lambda errors in API Gateway - Amazon API Gateway

answered 2 months ago
EXPERT
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.