HTTP 502 Bad Gateway — Upstream Server Error
About HTTP 502 Bad Gateway
HTTP 502 Bad Gateway means a gateway or proxy received an invalid response from the upstream server. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: Status: 502 Bad Gateway. Category: 5xx Server Error. Proxy/gateway received invalid upstream response. Usually a backend server issue. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: Backend server crashed or is down. Upstream server returned an invalid response. Load balancer cannot reach backend. PHP/Node/Python process died. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Wait and retry — often temporary. Check if the backend server is running. Review upstream server logs. Verify load balancer and proxy configuration. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our HTTP Status Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
What causes 502?
Usually the backend application crashed or is overloaded.
Overview
HTTP 502 Bad Gateway means a gateway or proxy received an invalid response from the upstream server.
Key Details
- Status: 502 Bad Gateway
- Category: 5xx Server Error
- Proxy/gateway received invalid upstream response
- Usually a backend server issue
Common Causes
- Backend server crashed or is down
- Upstream server returned an invalid response
- Load balancer cannot reach backend
- PHP/Node/Python process died
Steps
- 1Wait and retry — often temporary
- 2Check if the backend server is running
- 3Review upstream server logs
- 4Verify load balancer and proxy configuration