HTTP 502 — Bad Gateway
HTTP 502 is infrastructure gossip: a gateway or proxy upstream of the real service received an invalid answer — or none — and reports the broken conversation to the client. The client’s request was never the problem.
When 502 shows up
- A reverse proxy whose upstream process crashed mid-response.
- Load balancers pointing at a dead or misbehaving backend.
Mocking a 502 response
A response with this status can be faked end to end with a local mock rule — no backend changes needed. The configuration below mirrors the rule fields the ApiSimul editor uses (method, path, status, delay in milliseconds, response body):
{
"method": "GET",
"path": "/api/data",
"status": 502,
"delay": 400,
"enabled": true,
"body": {
"error": "bad_gateway",
"upstream": "unreachable"
}
}Dynamic placeholders such as {{random.name}}, {{string.uuid}} or {{number.int 1 100}} can appear inside the body to vary each response, which keeps client-side list rendering and retry logic honest during development.
Frequently asked questions
What does HTTP 502 mean?
The gateway got a bad response from the service behind it. Retry may help if the upstream recovers; otherwise the infrastructure needs attention.
How can I test a 502 response without a real backend?
Define a mock rule with the method and path your client requests and set the status to 502. The example configuration above returns this response after the listed delay, so the client exercises its 502 handling exactly as it would against a live server.
Related status codes
Need the response in your own project? Spin up rules for any status with the ApiSimul mock server, or browse every status code page.