# Runbook: API high error rate - Alert: `api_5xx_rate > 2% for 5m` - Service: Public API (`api` in production) - Owner: Platform team - Last tested: 2026-11-30 ## What the alert means More than 2% of API requests have returned a `5xx` status for five minutes. Customers see failed requests in the app and in their API integrations. ## First five minutes 1. Acknowledge the page so the next person isn't paged. 2. Open the [API dashboard](https://grafana.example.com/d/api) and check whether errors are rising or steady, and on which endpoints. 3. Check [recent deploys](https://github.com/acme/api/deployments). If a deploy finished in the last 30 minutes, go to [Roll back a deploy](#roll-back-a-deploy). 4. If customers are affected for more than 10 minutes, declare an incident in `#incidents` and post an update on the status page. ## Diagnose Check each in order and stop at the first that explains the errors. | Check | Command or link | If it shows a problem | | --- | --- | --- | | A recent deploy | `kubectl -n api rollout history deployment/api` | [Roll back a deploy](#roll-back-a-deploy) | | Database health | [Database dashboard](https://grafana.example.com/d/db) | [Database connections exhausted](#database-connections-exhausted) | | Pod restarts | `kubectl -n api get pods` | Read the logs of a restarting pod with `kubectl -n api logs --previous` | | A third-party outage | Status pages of the payment and email providers | Post on the status page and wait. Errors from these calls are retried. | ## Fixes ### Roll back a deploy ```bash kubectl -n api rollout undo deployment/api kubectl -n api rollout status deployment/api ``` The error rate should fall within five minutes. A rollback doesn't undo database migrations. If the deploy included a migration, check the error message before rolling back. ### Database connections exhausted Logs show `remaining connection slots are reserved`. Restart the API pods one at a time to release leaked connections: ```bash kubectl -n api rollout restart deployment/api ``` Then open an issue to find the leak. Don't raise `max_connections` during the incident. ## Verify The incident is over when the error rate stays under 0.5% for 15 minutes on the API dashboard. Post a final status page update. ## Escalate If none of the fixes work within 30 minutes, page the Platform team's secondary on-call. For database problems, also page the database owner.