What are HTTP Status Codes? A Deep Dive into Common Status Codes

HTTP Status Codes

Today, let’s talk about the topic of HTTP status codes! Whether you are a beginner or an experienced developer, HTTP status codes are an essential knowledge point that you must master! They can help you solve problems and improve your website’s performance and user experience. Are you ready? Let’s dive in!

What are HTTP Status Codes? A Deep Dive into Common Status Codes

Classification of Status Codes

HTTP status codes are divided into five categories, covering the complete process from informational responses to server errors:

  • 1xx (Informational Response): The request has been received and needs further processing. (#1xx Informational Response)
  • 2xx (Success): The request has been successfully processed. (#2xx Success)
  • 3xx (Redirection): Further action is required (e.g., redirection) to complete the request. (#3xx Redirection)
  • 4xx (Client Error): There is a syntax error in the request or insufficient permissions. (#4xx Client Error)
  • 5xx (Server Error): The server failed to process the request. (#5xx Server Error)

1xx Informational Response

Status Code Description Example Scenario
100 Continue The client should continue sending the request body
101 Switching Protocols Protocol switch (e.g., upgrade to WebSocket)
102 Processing WebDAV extension, indicating that the request is being processed

2xx Success

Status Code Description Example Scenario
200 OK The request was successful (e.g., webpage loaded or API returned data)
201 Created Resource created successfully (e.g., user registration)
202 Accepted The request has been accepted but not yet processed (asynchronous operation)
203 Non-Authoritative Non-authoritative information, the service successfully processed the request, but the information comes from another source
204 No Content The request was successful but there is no content returned (e.g., DELETE request)
205 Reset Content Reset content, the service successfully processed the request with no content returned
206 Partial Content Partial content response (supports resuming downloads)
207 Multi-Status WebDAV multi-status response (in XML format)
208 Already Reported WebDAV extension, the resource status has already been reported

3xx Redirection

Status Code Description Example Scenario
301 Moved Permanently The resource has been permanently redirected (update bookmarks)
302 Found The resource has been temporarily redirected (browser defaults to GET)
303 See Other Forces the use of the GET method to access the new URI
304 Not Modified Not modified, the webpage has not changed since the last request
307 Temporary Redirect Temporary redirection while maintaining the original request method
308 Permanent Redirect Permanent redirection while maintaining the original request method

4xx Client Error

Status Code Description Example Scenario
400 Bad Request Request syntax error (e.g., JSON format error)
401 Unauthorized Unauthenticated (requires login or token)
402 Payment Required Payment required for access (digital payment scenario)
403 Forbidden No permission to access (e.g., IP blocked)
404 Not Found The resource does not exist (path error or deleted)
405 Method Not Allowed HTTP method not supported (e.g., POST disabled)
406 Not Acceptable Not acceptable, the requested content characteristics cannot respond to the requested webpage
408 Request Timeout Request timeout, the server timed out waiting for the request
409 Conflict Conflict, the server encountered a conflict while processing the request
410 Gone The resource has been permanently deleted (requires 301 redirection)
429 Too Many Requests Request rate too high (rate limiting triggered)
451 Unavailable For Legal Reasons Unavailable for legal reasons

Sub-status Code Extensions (for example, in IIS):

  • 401.1: Login failed (incorrect password)
  • 403.1: Insufficient execution permissions (e.g., script directory permissions)
  • 404.1: Port access is blocked

5xx Server Error

Status Code Description Example Scenario
500 Internal Server Error General server error (code exception or configuration issue)
501 Not Implemented Request method not implemented (e.g., PATCH not supported)
502 Bad Gateway The gateway/proxy server received an invalid response
503 Service Unavailable Service unavailable (overloaded or undergoing maintenance)
504 Gateway Timeout Gateway timeout (upstream server did not respond)
505 HTTP Version Error HTTP version not supported, the server does not support the requested protocol version
507 Insufficient Storage Insufficient storage space (WebDAV scenario)
511 Network Authentication Required Network authentication required (e.g., public Wi-Fi login)

Sub-status Code Extensions (specific to IIS):

  • 500.12: Application restarting
  • 503.18: Application pool configuration error

Special Status Codes

Status Code Description Example Scenario
418 I’m a teapot April Fools’ Day joke (RFC 2324)
499 Client Closed Request The client actively closed the connection (Nginx extension)

Summary and Recommendations

  • Error Handling:
    • • 4xx errors require checking client request parameters, permissions, and caching strategies.
    • • 5xx errors require checking server logs, load, and dependent services.
  • Debugging Tools: Use browser developer tools (Network tab) to view status codes in real-time.

Leave a Comment