HTTP Status Codes
1xx Informational(100-199)
| Code | Name | Description |
|---|---|---|
| 100 | Continue | The server has received the request headers and the client should proceed to send the request body. |
| 101 | Switching Protocols | The requester has asked the server to switch protocols and the server has agreed to do so. |
| 102 | Processing | The server has received and is processing the request, but no response is available yet (WebDAV). |
| 103 | Early Hints | Used to return some response headers before final HTTP message. |
2xx Success(200-299)
| Code | Name | Description |
|---|---|---|
| 200 | OK | The request has succeeded. The meaning depends on the HTTP method. |
| 201 | Created | The request has been fulfilled and a new resource has been created. |
| 202 | Accepted | The request has been accepted for processing, but the processing has not been completed. |
| 203 | Non-Authoritative Information | The returned metadata is not exactly the same as available from the origin server. |
| 204 | No Content | The server successfully processed the request, but is not returning any content. |
| 205 | Reset Content | The server successfully processed the request, asks that the requester reset its document view. |
| 206 | Partial Content | The server is delivering only part of the resource due to a range header sent by the client. |
| 207 | Multi-Status | The message body that follows is an XML message with multiple independent response codes (WebDAV). |
| 208 | Already Reported | The members of a DAV binding have already been enumerated (WebDAV). |
| 226 | IM Used | The server has fulfilled a request for the resource, and the response is a representation of the result. |
3xx Redirection(300-399)
| Code | Name | Description |
|---|---|---|
| 300 | Multiple Choices | Indicates multiple options for the resource. |
| 301 | Moved Permanently | The requested resource has been permanently moved to a new URI. |
| 302 | Found | The requested resource has been temporarily moved to a different URI. |
| 303 | See Other | The response to the request can be found under another URI using the GET method. |
| 304 | Not Modified | The resource has not been modified since the version specified by the request headers. |
| 305 | Use Proxy | The requested resource must be accessed through the proxy given by the Location field. |
| 307 | Temporary Redirect | The request should be repeated with another URI, but future requests should still use the original URI. |
| 308 | Permanent Redirect | The request and all future requests should be repeated using another URI. |
4xx Client Error(400-499)
| Code | Name | Description |
|---|---|---|
| 400 | Bad Request | The server cannot process the request due to a client error (malformed syntax). |
| 401 | Unauthorized | Authentication is required and has failed or has not yet been provided. |
| 402 | Payment Required | Reserved for future use. Originally intended for digital payment systems. |
| 403 | Forbidden | The server understood the request, but is refusing to fulfill it. |
| 404 | Not Found | The requested resource could not be found on the server. |
| 405 | Method Not Allowed | The request method is not supported for the requested resource. |
| 406 | Not Acceptable | The requested resource is capable of generating only content not acceptable according to the Accept headers. |
| 407 | Proxy Authentication Required | The client must first authenticate itself with the proxy. |
| 408 | Request Timeout | The server timed out waiting for the request. |
| 409 | Conflict | The request could not be processed because of conflict in the current state of the resource. |
| 410 | Gone | The requested resource is no longer available and will not be available again. |
| 411 | Length Required | The request did not specify the length of its content, which is required by the requested resource. |
| 412 | Precondition Failed | The server does not meet one of the preconditions that the requester put on the request. |
| 413 | Payload Too Large | The request is larger than the server is willing or able to process. |
| 414 | URI Too Long | The URI provided was too long for the server to process. |
| 415 | Unsupported Media Type | The request entity has a media type which the server or resource does not support. |
| 416 | Range Not Satisfiable | The client has asked for a portion of the file, but the server cannot supply that portion. |
| 417 | Expectation Failed | The server cannot meet the requirements of the Expect request-header field. |
| 418 | I'm a teapot | The server refuses the attempt to brew coffee with a teapot (April Fools' joke, RFC 2324). |
| 421 | Misdirected Request | The request was directed at a server that is not able to produce a response. |
| 422 | Unprocessable Entity | The request was well-formed but was unable to be followed due to semantic errors (WebDAV). |
| 423 | Locked | The resource that is being accessed is locked (WebDAV). |
| 424 | Failed Dependency | The request failed because it depended on another request and that request failed (WebDAV). |
| 425 | Too Early | The server is unwilling to risk processing a request that might be replayed. |
| 426 | Upgrade Required | The client should switch to a different protocol. |
| 428 | Precondition Required | The origin server requires the request to be conditional. |
| 429 | Too Many Requests | The user has sent too many requests in a given amount of time (rate limiting). |
| 431 | Request Header Fields Too Large | The server is unwilling to process the request because its header fields are too large. |
| 451 | Unavailable For Legal Reasons | The server is denying access to the resource as a consequence of a legal demand. |
5xx Server Error(500-599)
| Code | Name | Description |
|---|---|---|
| 500 | Internal Server Error | The server encountered an unexpected condition that prevented it from fulfilling the request. |
| 501 | Not Implemented | The server does not support the functionality required to fulfill the request. |
| 502 | Bad Gateway | The server received an invalid response from an upstream server. |
| 503 | Service Unavailable | The server is currently unable to handle the request due to temporary overloading or maintenance. |
| 504 | Gateway Timeout | The server did not receive a timely response from an upstream server. |
| 505 | HTTP Version Not Supported | The server does not support the HTTP protocol version used in the request. |
| 506 | Variant Also Negotiates | Transparent content negotiation results in a circular reference. |
| 507 | Insufficient Storage | The server is unable to store the representation needed to complete the request (WebDAV). |
| 508 | Loop Detected | The server detected an infinite loop while processing the request (WebDAV). |
| 510 | Not Extended | Further extensions to the request are required for the server to fulfill it. |
| 511 | Network Authentication Required | The client needs to authenticate to gain network access. |
技术详情
HTTP 状态码速查表
工具功能
HTTP 状态码速查表列出了所有 IANA 注册的 HTTP 响应状态码,按 RFC 标准分类为 5 组(1xx-5xx)。每个状态码包含数字代码、原因短语、RFC 来源、详细说明和开发者实用指南。支持按类别筛选(信息、成功、重定向、客户端错误、服务器错误)和关键词搜索(如 "Not Found" 或 "429")。同时标注哪些状态码是标准必知的(如 200、301、404、500),哪些是非常见但有用的(如 418 I'm a teapot 的趣闻背景)。
常见开发者使用场景
HTTP 状态码速查表是每个 Web 开发者的必备参考。后端开发者在设计 RESTful API 时,正确选择状态码是 API 设计质量的关键——400 Bad Request vs 422 Unprocessable Entity 的选择体现了 API 设计的专业程度。前端开发者处理 API 响应时需要理解各类状态码的含义,特别是 401 vs 403 的区别(未认证 vs 已认证但无权限)。DevOps 在监控应用时根据 5xx 错误的出现频率判断服务器健康状况。面试中关于状态码的问题是高频考点。
配合 MIME 类型参考 了解 HTTP Headers 中的 Content-Type,或使用 API 测试器 实际测试各类状态码的 API 响应。
HTTP 状态码 5 大分类详解
所有状态码按百位数分组,每组有明确的语义:
- 1xx 信息性:100 Continue(继续发送请求体)、101 Switching Protocols(WebSocket 升级)。很少在应用层直接使用。
- 2xx 成功:200 OK(标准成功)、201 Created(资源创建成功)、204 No Content(成功但无返回体,常用于 DELETE)。
- 3xx 重定向:301 Moved Permanently(永久重定向/SEO 迁站)、302 Found(临时重定向)、304 Not Modified(缓存命中)。
- 4xx 客户端错误:400 Bad Request(请求格式错误)、401 Unauthorized(需要认证)、403 Forbidden(无权访问)、404 Not Found(不存在的资源)、429 Too Many Requests(限流)。
- 5xx 服务器错误:500 Internal Server Error(未捕获的服务器异常)、502 Bad Gateway(上游服务错误)、503 Service Unavailable(维护或过载)。
常见陷阱与注意事项
- 401 vs 403 的区别:401 表示"请先登录"(未认证),会触发浏览器弹出认证对话框。403 表示"你已经登录,但没有权限"(已认证但无授权)。这是最常混淆的两个状态码。
- 200 vs 204:DELETE 操作成功后返回 204 No Content 更语义化(确实没有内容返回),返回 200 也可以但不够精确。
- 自定义状态码:不要在项目中发明自定义状态码。虽然技术可行性存在,但它破坏了 HTTP 协议的标准化语义,导致通用中间件和监控工具无法正确解读。
- 418 I'm a teapot:这来自 1998 年愚人节 RFC 2324(超文本咖啡壶控制协议),但许多框架至今保留了这个状态码作为内部玩笑。
何时使用此工具而非代码
在 API 设计决策时选择正确的状态码、排查 HTTP 错误的含义、或准备技术面试时使用此参考表。