Skip to content

Sporadic 502 Errors with Lambda and API Gateway

0

Hi, I have my Express "server" (serverless routes) configured in AWS Lambda behind API Gateway, with the Lambda having 20 units of provisioned concurrency to prevent cold starts. My API serves our Android and iOS mobile apps and our web backend. Often, on seemingly random requests, I get a 502 failed to fetch response. I don't believe I have the timeout set to anything crazy low that would be causing this, and it shouldn't be the status code it returns as the same request works upon refresh of the web app, as an example (retrying the request). It almost seems like this happens when there is less server volume rather than more. Thanks.

3 Answers
0

Hi,

Please, read this KC article about 502 errors with API GTW: https://repost.aws/knowledge-center/malformed-502-api-gateway

It details possible causes and provides solutions to fix.

Best,

Didier

EXPERT
answered a year ago
0

I also get this behavior from my modestly but constantly loaded endpoint.

I have a suspicion that the lambda serving the request is being killed whilst serving the request as it exceeds the 30s execution timeout but could be totally wrong.

I have tracing enabled and it shows nothing out of the ordinary.

answered a year ago
0

I too am getting this happening on a reasonably regular basis. Nothing has been changed in the API Gateway or connected Lambda function in over 7 days yet suddenly this morning I'm getting a 502 Bad Gateway response on just one API - I believe this us actually a platform issue. It would be good if AWS could investigate.....

answered 10 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.