为了让你不必每次都去查规范,我们按区间整理了实际工作中最常遇到的状态码。点击下方列表中的每个代码,即可进入包含含义、发生场景、原因与解决方法的详情页。
快速判断标准:2xx 表示成功,3xx 表示跳转(重定向),4xx 表示请求(客户端)问题,5xx 表示服务器问题。看到 4xx 时先检查请求 URL、请求头和认证;看到 5xx 时先检查服务器日志和后端状态。
常用状态码一览
2xx成功 (Success)
3xx重定向 (Redirection)
4xx客户端错误 (Client Error)
400Bad Request 常用The server cannot process the request due to a client error such as malformed syntax.401Unauthorized 常用Authentication is required and has failed or not been provided (i.e. unauthenticated).403Forbidden 常用The server understood the request but refuses to authorize it. Re-authenticating will not help.404Not Found 常用The server cannot find the requested resource. The most well-known status code.405Method Not Allowed 常用The HTTP method is known but not supported for the target resource.409Conflict 常用The request conflicts with the current state of the resource.422Unprocessable Content 常用The request is well-formed but has semantic errors (e.g. validation failed).429Too Many Requests 常用The client has sent too many requests in a given time (rate limiting).
5xx服务器错误 (Server Error)
500Internal Server Error 常用A generic catch-all: the server hit an unexpected condition and could not complete the request.502Bad Gateway 常用A gateway or proxy received an invalid response from an upstream server.503Service Unavailable 常用The server is temporarily unable to handle the request due to overload or maintenance.504Gateway Timeout 常用A gateway or proxy did not get a timely response from an upstream server.