502 Bad Gateway

HTTP 502 錯誤閘道器 伺服器錯誤響應狀態碼錶明伺服器作為閘道器或代理,從上游伺服器接收到無效響應。

此響應類似於 500 內部伺服器錯誤 響應,因為它是一個通用的伺服器錯誤“包羅永珍”。區別在於它專門針對請求鏈中發生錯誤的位置。如果源伺服器向閘道器傳送有效的 HTTP 錯誤響應,則該響應應傳遞給客戶端而不是 502,以使故障原因透明。如果代理或閘道器未從源接收到任何 HTTP 響應,它會改為向客戶端傳送 504 閘道器超時

導致 502 錯誤的原因有很多,解決此類問題可能需要伺服器所有者或管理員進行調查。例外情況是客戶端網路錯誤,特別是如果該服務適用於其他訪問者,以及客戶端使用 VPN 或其他自定義網路設定的情況。在這種情況下,客戶端應檢查網路設定、防火牆設定、代理設定、DNS 配置等。

狀態

http
502 Bad Gateway

示例

502 閘道器錯誤響應

以下請求嘗試獲取網頁,但返回 502 響應。響應正文包含描述伺服器狀態的頁面,其中包含指向訪問者支援頁面的連結。

http
GET /highlights HTTP/1.1
Host: example.com
User-Agent: curl/8.6.0
Accept: */*
http
HTTP/1.1 502 Bad Gateway
Content-Type: text/html;
Content-Length: 123

<!doctype html>
<html lang="en">
<head>
  <title>502 Bad Gateway</title>
</head>
<body>
  <h1>Bad Gateway</h1>
  <p>The server was unable to complete your request. Please try again later.</p>
  <p>If this problem persists, please <a href="https://example.com/support">contact support</a>.</p>
</body>
</html>

規範

規範
HTTP 語義
# status.502

另見