HTTP 502 Bad Gateway
The server received an invalid response from an upstream server while acting as a gateway.
Bad Gateway
The server received an invalid response from an upstream server while acting as a gateway.
What Causes HTTP 502?
- Upstream server is down or unreachable
- Proxy or load balancer configuration error
- Upstream server returned an invalid response
- Network connectivity issues between services
- Upstream server timeout
Code Examples
See how HTTP 502 responses look in different programming languages and tools.
curl -X GET https://api.example.com/resource
# Response: 502 Bad Gateway
# The gateway/proxy cannot reach the upstream serverHow to Fix HTTP 502
- Check if upstream services are running and healthy
- Verify proxy and load balancer configurations
- Implement health checks for upstream services
- Add retry logic with exponential backoff
- Monitor upstream service availability
Related Status Codes
The server encountered an unexpected condition that prevented it from fulfilling the request.
The server is temporarily unable to handle the request due to maintenance or overload.
The server did not receive a timely response from an upstream server while acting as a gateway.
The request was malformed or invalid. The server cannot process it.
Rate limit exceeded. The client has sent too many requests in a given time period.
Test Your APIs
Frequently Asked Questions
What does HTTP 502 mean?
The server received an invalid response from an upstream server while acting as a gateway.
What causes HTTP 502?
Upstream server is down or unreachable. Proxy or load balancer configuration error. Upstream server returned an invalid response. Network connectivity issues between services. Upstream server timeout
How to fix HTTP 502?
Check if upstream services are running and healthy. Verify proxy and load balancer configurations. Implement health checks for upstream services. Add retry logic with exponential backoff. Monitor upstream service availability