API Gateway has high 5xx error percentage
Why do I see this?
One of your API endpoints has a high 5xx error rate.
What does this mean?
API gateway uses the HTTP response codes to convey errors. 5xx errors are server-side errors that are indicated by the 5xx HTTP response code. These codes range from 500 to 599 and can mean many things including:
- 500 Error: Internal Server Error
- 502 Error: Bad Gateway
- 503 Error: Service Unavailable
- 504 Error: Endpoint Request Timed-out
This event warns you when one of your API endpoints has shown to have a high 5XX error percentage in the last 15 minutes.
How do I fix "API Gateway has high 5xx error percentage"?
The first thing to do is to make sure you have enabled execution logging and access logging in your Amazon CloudWatch Logs. That will make sure that data such as the total count of the server-side errors can be captured.
These errors can be caused due to many reasons including incompatible upgrades, incorrect error mapping, missing or corrupt files, incorrect permissions, broken API integration with AWS services, or errors in the Lambda function code.
You can start by looking into your Lambda code and making sure it's bug-free. For errors indicating incorrect error mapping, you can set up mock integrations. Some 5xx errors are also caused if you've exceeded the service quota limit, so check your API Gateway quota limit.
As a general rule to troubleshoot 5xx errors, you can make sure you follow and adhere to AWS' developer guide to working with API gateways.
You can also check out this detailed developer guide to troubleshooting 5xx errors for API Gateway.