HTTP Status Codes
One input per line. Output is numbered to match the input order.
Pinned tools are listed in your favourites on the home page.Copies a link to this tool that carries your current input, so it opens ready to run.Gives you an iframe snippet for putting this tool on your own site.
1xx Informational
2xx Success
3xx Redirection
4xx Client Error
5xx Server Error
Ctrl+Enter Run · Ctrl+Shift+C Copy · Esc Clear
Understand HTTP Status Codes
一份可搜索的标准 HTTP 状态码参考,从 100 Continue 到 511 Network Authentication Required,说明每一个到底意味着什么。
How it works
HTTP 状态码按首位数字分组:1xx 是信息性的,2xx 表示成功,3xx 表示跳转,4xx 归咎于请求,5xx 归咎于服务器。这个数字就是契约——不认识 429 的客户端仍然必须把它当作通用的 4xx 处理,而不能盲目重试。真正的含义体现在同一类内部的区分上:301 和 308 都是永久跳转,但只有 308 禁止客户端在跳转时把方法改写为 GET,这就是永久迁移的 POST 端点需要 308 的原因。本页是一张本地查询表,它不会发出任何请求。
When to use it
- 决定 API 端点在校验失败时该返回哪个码(结构正确但语义有误的请求体用 422,格式错误的输入用 400)
- 阅读 CDN 或负载均衡器日志,把源站故障(502、504)与源站自己报告的错误(500)区分开
- 在 URL 迁移时于 301、302、307 和 308 之间做选择,同时不破坏 POST 请求和 SEO
- 向同事解释为什么一个「看起来已登录」的请求返回的是 403 而不是 401
Watch out for
- 401 意为「未认证」,403 意为「已认证但不被允许」——这两个名字与直觉相反,因为叫 Unauthorized 的那个才是索要凭据的。
- 200 响应里同样可能装着错误。很多 API 会以 200 状态返回 {"error": ...},因此仅凭状态码不能判断成功——请检查响应体。
- 418 I'm a Teapot 出自 RFC 2324,是 1998 年的愚人节玩笑。它真实到有服务器实现了它,但它并不属于 HTTP 标准。
- 511 以上的码或已注册集合之外的码在链路上是合法的——代理和 WAF 会自造状态码(例如 Cloudflare 的 5xx 区段)。在这里找不到的码,多半是厂商专有的。
Frequently Asked Questions
401 和 403 有什么区别?
401 Unauthorized 表示客户端未通过认证——你需要登录或提供有效凭据。403 Forbidden 表示服务器知道你是谁,但你没有访问该资源的权限。401 是在索要凭据;403 是在拒绝它们。
什么时候该用 301,什么时候用 302 跳转?
301(Moved Permanently)告诉浏览器和搜索引擎永久更新缓存的链接——用于对 SEO 安全的 URL 变更。302(Found / 临时跳转)表示原 URL 仍然有效——用于 A/B 测试、维护页面或短期跳转。
502 Bad Gateway 是什么原因造成的?
502 表示作为代理的服务器(nginx、CDN、负载均衡器)从上游服务器收到了无效响应。常见原因:源站宕机、超时,或返回了格式错误的 HTTP。请先查看源站的健康日志。
How to Use HTTP Status Codes
- Paste or type your input in the input area above.
- The tool processes your input automatically or click Run.
- Copy or download the result using the action buttons.
- Use Ctrl+Enter to run quickly from the keyboard.