HTTP Status Codes Cheatsheet - HTTP Response Status Code Reference
A status code usually tells you where to look next instead of where to blame. Grouped by 1xx–5xx, each entry gives the meaning, typical cause and a fix hint, covering both REST responses returned to clients and edge-level errors such as Nginx forwarding and rate limiting. Use it to read logs, align client–server contracts, and tell 401/403 or 302/307 apart for real environments.
1xx Informational 2
100 Continue101 Switching Protocols2xx Success 5
200 OK201 Created202 Accepted204 No Content206 Partial Content3xx Redirection 6
301 Moved Permanently302 Found303 See Other304 Not Modified307 Temporary Redirect308 Permanent Redirect4xx Client Error 17
400 Bad Request401 Unauthorized403 Forbidden404 Not Found405 Method Not Allowed406 Not Acceptable408 Request Timeout409 Conflict410 Gone413 Payload Too Large415 Unsupported Media Type418 I'm a teapot422 Unprocessable Entity426 Upgrade Required429 Too Many Requests431 Request Header Fields Too Large451 Unavailable For Legal Reasons5xx Server Error 8
500 Internal Server Error501 Not Implemented502 Bad Gateway503 Service Unavailable504 Gateway Timeout505 HTTP Version Not Supported507 Insufficient Storage511 Network Authentication RequiredTypical Use Case
When an integration request returns 500, start in the 5xx section to tell app-exception from gateway failure; a 401 means you first need a Token or login, while 403 means authenticated but not authorized, so check API permissions against the 4xx semantics; on Nginx 413/429, follow the code-level fix to raise the body limit or tune rate limiting; after reading, a bare status code tells you whether to check logs, change the request, or adjust server/gateway config.
Command Examples
Show only the HTTP status code of an API
curl -s -o /dev/null -w "%{http_code}\n" https://api.example.com/users/1用 curl 丢弃响应体只输出状态码:200 成功、404 路径不符、401 缺凭证、500 服务端异常,适合一行判断接口是否可用。
Output
200
Count 5xx responses in the Nginx access log
awk '$9 ~ /^5[0-9][0-9]$/ {print $9}' /var/log/nginx/access.log | sort | uniq -c区别权重:502 是拿到上游无效响应(后端崩溃/拒绝连接),504 是连接成功但等待超时,据此决定查后端进程还是调高 proxy timeouts。
Output
3 502
5 504Check when to retry after a 429 rate-limit
curl -i https://api.example.com/search?q=laohand429 表示触发限流,优先读取 Retry-After 响应头(单位秒)再重试,避免继续打爆接口或被封禁。
Output
HTTP/1.1 429 Too Many Requests Retry-After: 120
Common Pitfalls
- Never bury business errors in 200: if the API signals failure via 200 + a body error code, clients cannot judge success from the status alone — an anti-pattern.
- 301 gets cached by browsers/clients: clear cache or use 302 before changing the origin URL, otherwise you keep seeing the old redirect.
- 400 vs 422 both mean a bad request: 400 is malformed syntax/structure, 422 is an invalid field value (semantic).
- Do not confuse 502 with 503: 502 means the gateway got an invalid upstream response, 503 means the service is actively down; mixing them misleads alerting.
- Check whether a proxy rewrote the response: Nginx default error pages can mask the real upstream status during debugging.
Tips
- 502 vs 504: 502 means the backend returned an invalid response (crash/refused); 504 means connected but timed out.
- 401 vs 403: 401 is 'who are you' (unauthenticated); 403 is 'you can't' (authenticated, no permission).
- Nginx 413: raise client_max_body_size; 429: check the limit_req rate-limiting config.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us