Bird
0
0

You deployed an API Gateway with Lambda integration but receive a 502 Bad Gateway error when calling the API. What is the most likely cause?

medium📝 Debug Q14 of 15
AWS - Serverless Architecture
You deployed an API Gateway with Lambda integration but receive a 502 Bad Gateway error when calling the API. What is the most likely cause?
AAPI Gateway endpoint URL is incorrect
BLambda function is not returning a properly formatted response
CLambda function has no execution role assigned
DAPI Gateway method is set to MOCK integration
Step-by-Step Solution
Solution:
  1. Step 1: Understand 502 Bad Gateway meaning

    502 error usually means API Gateway received an invalid response from Lambda.
  2. Step 2: Check Lambda response format

    Lambda must return an object with statusCode and body as string; missing or malformed response causes 502.
  3. Final Answer:

    Lambda function is not returning a properly formatted response -> Option B
  4. Quick Check:

    502 error = bad Lambda response format [OK]
Quick Trick: 502 means Lambda response format error [OK]
Common Mistakes:
  • Assuming wrong API Gateway URL causes 502
  • Ignoring Lambda execution role issues (causes 403)
  • Confusing MOCK integration with Lambda integration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes