HTTP 状态码参考 - 完整状态码指南

免费在线 HTTP 状态码参考工具。搜索和浏览所有 HTTP 响应状态码,包含描述、分类和常见使用场景。

1xx Informational

100
Continue

The server has received the request headers and the client should proceed.

101
Switching Protocols

The server is switching protocols as requested (e.g., WebSocket upgrade).

2xx Success

200
OK

The request succeeded. Standard response for successful HTTP requests.

201
Created

The request succeeded and a new resource was created. Common after POST requests.

204
No Content

The request succeeded but there is no content to return. Common for DELETE.

206
Partial Content

The server is delivering only part of the resource due to a range header.

3xx Redirection

301
Moved Permanently

The resource has been permanently moved to a new URL. Use for SEO redirects.

302
Found

The resource is temporarily at a different URL. Often used in OAuth redirects.

304
Not Modified

The resource has not been modified since the last request. Use cached version.

307
Temporary Redirect

Like 302 but preserves the HTTP method. Used in HSTS redirects.

308
Permanent Redirect

Like 301 but preserves the HTTP method.

4xx Client Error

400
Bad Request

The server cannot process the request due to invalid syntax or parameters.

401
Unauthorized

Authentication is required. The client must provide valid credentials.

403
Forbidden

The client does not have permission to access the resource, even with auth.

404
Not Found

The requested resource does not exist on the server.

405
Method Not Allowed

The HTTP method is not supported for the requested resource.

409
Conflict

The request conflicts with the current state of the resource.

410
Gone

The resource is permanently gone and will not be available again.

413
Payload Too Large

The request body exceeds the server limit.

415
Unsupported Media Type

The media type in the request is not supported by the server.

422
Unprocessable Entity

The request is well-formed but contains semantic errors (used in APIs).

429
Too Many Requests

The user has sent too many requests in a given time. Rate limiting.

5xx Server Error

500
Internal Server Error

Generic server error. Something unexpected went wrong.

502
Bad Gateway

The server received an invalid response from an upstream server.

503
Service Unavailable

The server is temporarily unable to handle the request (maintenance/overload).

504
Gateway Timeout

The upstream server did not respond in time.

什么是 HTTP 状态码?

HTTP 状态码是 Web 服务器在响应客户端请求时返回的三位数字。它们指示请求是否成功、被重定向、导致客户端错误还是引起服务器错误。状态码分为五个类别:1xx(信息性)、2xx(成功)、3xx(重定向)、4xx(客户端错误)和 5xx(服务器错误)。理解这些状态码对于需要构建、调试和监控 Web 应用程序和服务的 Web 开发人员、API 设计者和系统管理员来说至关重要。

如何使用 HTTP 状态码参考

  1. 浏览按类别(1xx 到 5xx)组织的完整 HTTP 状态码列表。
  2. 使用搜索框按数字、名称或描述过滤状态码——例如,输入 '404' 或 'redirect'。
  3. 每个状态码显示其数字代码、官方名称以及何时和如何使用的简明描述。
  4. 颜色编码的类别使您能轻松区分成功(绿色)、重定向(黄色)、客户端错误(橙色)和服务器错误(红色)。
  5. 在调试 API 响应、配置 Web 服务器或编写错误处理逻辑时使用此参考。

常见使用场景

  • API 开发 — 在设计 REST API 响应时选择正确的状态码——了解何时使用 201 而非 200,或 400 而非 422,有助于设计更好的 API。
  • 调试 HTTP 错误 — 当 API 返回意外状态码时,快速查找其含义以了解问题出在客户端还是服务器端。
  • SEO 与重定向 — 理解 301(永久)和 302(临时)重定向之间的区别及其对搜索引擎优化的影响。
  • 错误页面设计 — 在实现 404、403、500 和其他常见错误场景的自定义错误页面时参考正确的状态码。

FAQ

401 和 403 有什么区别?
401 Unauthorized 表示请求缺少有效的认证凭据——用户需要登录。403 Forbidden 表示服务器理解了请求且用户可能已通过认证,但没有权限访问该资源。
什么时候应该使用 200、201 还是 204?
200 OK 用于成功的 GET 请求和一般性成功。201 Created 用于成功创建新资源的 POST 请求之后。204 No Content 用于不返回响应体的成功请求,如 DELETE 操作。
301 和 308 重定向有什么区别?
两者都是永久重定向。301 允许客户端更改 HTTP 方法(例如,POST 可能变为 GET)。308 要求客户端保留原始 HTTP 方法。对于大多数网站重定向,301 是标准选择;308 在需要保持方法不变时使用。

相关工具