What Are HTTP Status Codes
HTTP status codes are three-digit identifiers in server responses that indicate the result of a client's request. Every HTTP response includes a status code telling the client whether the request succeeded, failed, or requires further action.
Status Code Categories
1xx: Informational
Indicates the request has been received and further processing is needed.
| Code | Name | Description | |------|------|-------------| | 100 | Continue | Server received request headers; client should continue sending body | | 101 | Switching Protocols | Server agrees to switch protocols (e.g., WebSocket upgrade) | | 102 | Processing | Server is processing the request (WebDAV) |
2xx: Success
Indicates the request was successfully received, understood, and processed.
| Code | Name | Description | |------|------|-------------| | 200 | OK | Request succeeded (most common) | | 201 | Created | Request succeeded and a new resource was created (POST success) | | 202 | Accepted | Request accepted but not yet processed (async operations) | | 204 | No Content | Request succeeded with no response body (DELETE success) | | 206 | Partial Content | Server returned only part of the resource (range requests) |
3xx: Redirection
Indicates the client needs to take additional action to complete the request.
| Code | Name | Description | |------|------|-------------| | 301 | Moved Permanently | Resource permanently moved to new URL (SEO-friendly) | | 302 | Found | Resource temporarily moved to new URL | | 304 | Not Modified | Resource unchanged; use cached version | | 307 | Temporary Redirect | Temporary redirect, preserves request method | | 308 | Permanent Redirect | Permanent redirect, preserves request method |
4xx: Client Errors
Indicates the client sent a problematic request.
| Code | Name | Description | |------|------|-------------| | 400 | Bad Request | Malformed request (missing params, JSON parse error) | | 401 | Unauthorized | Not authenticated (login required) | | 403 | Forbidden | Authenticated but no permission | | 404 | Not Found | Resource doesn't exist (the classic error) | | 405 | Method Not Allowed | HTTP method not permitted for this resource | | 409 | Conflict | Resource conflict (e.g., creating a duplicate) | | 413 | Payload Too Large | Request body too big | | 422 | Unprocessable Entity | Syntactically correct but semantically invalid (validation failure) | | 429 | Too Many Requests | Rate limit exceeded |
5xx: Server Errors
Indicates the server failed to fulfill a valid request.
| Code | Name | Description | |------|------|-------------| | 500 | Internal Server Error | Generic server error (code bug, uncaught exception) | | 502 | Bad Gateway | Gateway/proxy received an invalid response | | 503 | Service Unavailable | Server temporarily unavailable (overloaded or maintenance) | | 504 | Gateway Timeout | Gateway/proxy timed out |
How to Use the HTTP Status Code Tool
Using DevToolkit Pro's HTTP Status Codes:
- Enter a status code (e.g.,
404) - View the name, category, and detailed description
- Search by keyword (e.g., "not found")
- Get usage examples and code snippets
API Status Code Best Practices
RESTful API Convention
// GET /users/123
// Success
200 OK → { "id": 123, "name": "Alice" }
// Not found
404 Not Found → { "error": "User not found" }
// POST /users
// Created
201 Created → { "id": 124, "name": "Bob" }
// Validation failed
422 Unprocessable Entity → { "errors": ["Email is required"] }
// DELETE /users/123
// Deleted
204 No Content → (empty body)
// PUT /users/123
// Not authenticated
401 Unauthorized → { "error": "Token expired" }
// No permission
403 Forbidden → { "error": "Insufficient permissions" }
Don't Abuse 200
Returning 200 OK for all responses is a common anti-pattern:
// ❌ Wrong
res.status(200).json({ success: false, error: "User not found" });
// ✅ Correct
res.status(404).json({ error: "User not found" });
FAQ
What's the Difference Between 404 and 410?
404 means the resource might exist but wasn't found (could be temporary). 410 means the resource existed but has been permanently deleted — clients should stop requesting it.
When Should I Use 500 vs 503?
500 is an internal server error (code bug, uncaught exception). 503 means the service is temporarily unavailable (overload, maintenance, dependency failure).
What Should a 429 Response Include?
Include a Retry-After header telling the client when to retry. You can also use X-RateLimit-Reset to return the reset timestamp.
This article is brought to you by DevToolkit Pro. More developer tools at the homepage.
相关文章
Online Word Counter: Count Words, Characters, Lines Instantly
Learn how to use an online word counter to count words, characters, lines, and paragraphs. Understand Chinese vs English counting differences and use cases in writing and development.
UUID Generator: Complete Guide to Unique Identifiers (UUID, NanoID, ULID)
Understand UUID v4, NanoID, and ULID fundamentals. Learn how to use an online UUID generator, and discover best practices for databases, distributed systems, and API tracking.
Online User-Agent Parser: Identify Browser and Device Information
Learn how to parse User-Agent strings. Understand browser, operating system, and device type identification methods, and applications in data analytics and compatibility testing.