HTTP 402 Payment Required vs 502 Bad Gateway
HTTP 402 (Payment Required) is a 4xx Client Error response, while 502 (Bad Gateway) is a 5xx Server Error response. 402 indicates that reserved for future use. Originally intended for digital payment systems, some APIs use it to indicate a billing or subscription issue. In contrast, 502 means that the server, acting as a gateway or proxy, received an invalid response from the upstream server.
Description
Reserved for future use. Originally intended for digital payment systems, some APIs use it to indicate a billing or subscription issue.
When You See It
On some APIs when a subscription has expired or payment is needed.
How to Fix
Check your billing status, update payment method, or upgrade your subscription.
Description
The server, acting as a gateway or proxy, received an invalid response from the upstream server.
When You See It
When Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).
How to Fix
Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.
Key Differences
402 is a 4xx Client Error response, while 502 is a 5xx Server Error response.
HTTP 402: Reserved for future use. Originally intended for digital payment systems, some APIs use it to indicate a billing or subscription issue.
HTTP 502: The server, acting as a gateway or proxy, received an invalid response from the upstream server.
You encounter 402 when on some APIs when a subscription has expired or payment is needed.
You encounter 502 when when Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).
When to Use Which
For 402 (Payment Required): Check your billing status, update payment method, or upgrade your subscription. For 502 (Bad Gateway): Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.