HTTP 415 Unsupported Media Type vs 502 Bad Gateway
HTTP 415 (Unsupported Media Type) is a 4xx Client Error response, while 502 (Bad Gateway) is a 5xx Server Error response. 415 indicates that the server refuses to accept the request because the Content-Type is not supported. In contrast, 502 means that the server, acting as a gateway or proxy, received an invalid response from the upstream server.
Description
The server refuses to accept the request because the Content-Type is not supported.
When You See It
When sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
How to Fix
Set the correct Content-Type header matching the data format you're sending.
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
415 is a 4xx Client Error response, while 502 is a 5xx Server Error response.
HTTP 415: The server refuses to accept the request because the Content-Type is not supported.
HTTP 502: The server, acting as a gateway or proxy, received an invalid response from the upstream server.
You encounter 415 when when sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
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 415 (Unsupported Media Type): Set the correct Content-Type header matching the data format you're sending. For 502 (Bad Gateway): Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.