Home Computer Science HTTP Status Code Cheat Sheet - From Informational (1xx) to Server Errors (5xx)

Table of content:
Arrow Btn

HTTP Status Code Cheat Sheet - From Informational (1xx) to Server Errors (5xx)

HTTP Status Code Cheat Sheet - From Informational (1xx) to Server Errors (5xx)

In the vast world of the internet, HTTP (HyperText Transfer Protocol) is the backbone enabling communication between clients (browsers) and servers. An essential component of this communication is HTTP status codes, which inform users and developers about the results of their requests. 


What Are HTTP Status Codes?

HTTP status codes are three-digit numbers returned by a server to indicate the result of an HTTP request. These codes provide a concise summary of the outcome, such as success, failure, or redirection.

For example, the status code 404 indicates a "Page Not Found" error, while 200 signifies a successful request.


Categories of HTTP Status Codes

HTTP status codes are divided into five categories, each representing a specific type of response:

Category Code Range Description
1xx 100–199 Informational responses
2xx 200–299 Success responses
3xx 300–399 Redirection messages
4xx 400–499 Client-side errors
5xx 500–599 Server-side errors

Complete List of HTTP Status Codes

1xx Informational Responses (Acknowledgment of Request Received)

Code Description Use Case Example
100 Continue Client should continue with the request. Chunked uploads in HTTP/1.1.
101 Switching Protocols Server switches to a different protocol. HTTP to WebSocket protocol upgrade.
102 Processing Server has received and is processing the request. WebDAV operations requiring long processing times.
103 Early Hints Used to send links for preload before final response. Preloading scripts and stylesheets.
104 Request in Progress (Proposed) Indicates a request is still being processed. Reserved for future extensions.

2xx Successful Responses (Indicating Success)

Code Description Use Case Example
200 OK Standard response for a successful request. Page loads successfully.
201 Created Resource successfully created on the server. New user registration API.
202 Accepted Request accepted but not yet processed. Queue-based API processing.
203 Non-Authoritative Information Proxy-modified response with non-original metadata. Proxies serving modified metadata.
204 No Content Request successful with no content to return. Updating user preferences silently.
205 Reset Content Instructs the client to reset the form used for submission. Clearing a search filter form.
206 Partial Content Partial resource delivered for range requests. Streaming video in chunks.
207 Multi-Status Used in WebDAV for multiple responses in a single request. Handling batch operations in WebDAV.
208 Already Reported Avoids repeatedly reporting the same internal member resource. Complex WebDAV operations.
226 IM Used Server successfully applied an instance-manipulation to the response. Delta encoding in HTTP.

3xx Redirection Responses (Further Action Needed)

Code Description Use Case Example
300 Multiple Choices Several resource representations available. Redirecting users to localized versions of content.
301 Moved Permanently Resource has been permanently moved to a new URL. Website domain migration.
302 Found Temporary redirect for the requested resource. Redirecting during site maintenance.
303 See Other Resource located at a different URI; client should use GET. Redirecting after POST submission.
304 Not Modified Cached version of resource is valid. Optimizing web performance.
305 Use Proxy Resource must be accessed through a proxy. Deprecated due to security concerns.
306 Switch Proxy Reserved; no longer used. Historic placeholder for redirection.
307 Temporary Redirect Temporary redirect without changing the HTTP method. API endpoint undergoing testing.
308 Permanent Redirect Permanent redirect with HTTP method unchanged. SEO-friendly permanent URL redirection.

4xx Client Error Responses (Client Faults)

Code Description Use Case Example
400 Bad Request Malformed or invalid request syntax. Missing query parameters in API calls.
401 Unauthorized Authentication required but not provided. Accessing protected resources.
402 Payment Required Reserved for future use; sometimes used for paywalls. Experimental use in APIs requiring payment.
403 Forbidden Client is not allowed access to the resource. Unauthorized access to admin panels.
404 Not Found Resource could not be found. Broken links or deleted pages.
405 Method Not Allowed HTTP method not supported for the resource. Using GET on an endpoint requiring POST.
406 Not Acceptable Response content not acceptable based on headers. Request for unsupported MIME types.
407 Proxy Authentication Required Proxy authentication required. Accessing content behind a proxy.
408 Request Timeout Server timed out waiting for the request. Poor network conditions.
409 Conflict Request conflicts with the server’s state. Editing the same document simultaneously.
410 Gone Resource permanently removed without a forwarding address. Deprecated or deleted API endpoints.
411 Length Required Content-Length header missing. Uploading files without specifying size.
412 Precondition Failed Preconditions given in headers were false. Conditional API requests with If-Match.
413 Payload Too Large Request entity is larger than the server can handle. Uploading oversized files.

5xx Server Error Responses (Server Faults)

Code Description Use Case Example
500 Internal Server Error Generic server error response. Debugging unhandled server exceptions.
501 Not Implemented Server does not support the functionality required. API feature under development.
502 Bad Gateway Invalid response from an upstream server. Load balancer receiving corrupted data.
503 Service Unavailable Server temporarily unavailable due to overload. High-traffic spikes or maintenance.
504 Gateway Timeout Upstream server failed to respond in time. APIs with long processing times.
505 HTTP Version Not Supported Server does not support the HTTP protocol version. Legacy HTTP versions in modern servers.
506 Variant Also Negotiates Circular references in negotiation process. Misconfigured content negotiation.
507 Insufficient Storage Server cannot store the representation. Cloud-based file storage limits.
508 Loop Detected Infinite loop detected during request processing. Complex WebDAV queries.
510 Not Extended Extensions required to fulfill the request. Proprietary protocol extensions.

Reserved and Deprecated Codes

Code Description Status
418 I’m a teapot Joke code from RFC 2324.
306 Switch Proxy Reserved.
402 Payment Required Reserved for future use.

Practical Examples of HTTP Status Codes

  1. 404 Not Found:

    • Example: Requesting https://example.com/nonexistentpage.html.
    • Response:
       
      HTTP/1.1 404 Not Found Content-Type: text/html
  2. 301 Moved Permanently:

    • Example: Redirecting http://example.com to https://example.com.
  3. 200 OK:

    • Example: A successful API request for user data.

FAQs

  1. What are HTTP status codes?
    They are three-digit numbers indicating the result of an HTTP request.

  2. Why are HTTP status codes important?
    They help in debugging and improving user experience.

  3. What does 302 Found mean?
    It’s a temporary redirection to another URL.

  4. How do I fix a 404 error?
    Ensure the requested resource exists or implement proper redirects.

  5. What is the difference between 4xx and 5xx?
    4xx indicates client errors; 5xx signifies server issues.

  6. What is 503 Service Unavailable?
    It means the server is overloaded or under maintenance.

  7. How do status codes impact SEO?
    Codes like 301 and 404 can influence search engine rankings.

  8. What does 204 No Content mean?
    The server successfully processed the request but returns no content.

  9. Why use 410 Gone instead of 404?
    410 explicitly tells that the resource is permanently removed.

  10. What does 500 Internal Server Error indicate?
    It signifies a generic server issue requiring debugging.


To err is human, and while we have put our best effort into ensuring this content is accurate and helpful, there is always room for improvement! If you spot any errors or think of ways to make this article even better, please feel free to reach out. Your feedback is invaluable; we are always happy to learn from you. Thank you for reading!


Here are 5 suggested reads for you:

Shivangi Vatsal
Sr. Associate Content Strategist @Unstop

I am a storyteller by nature. At Unstop, I tell stories ripe with promise and inspiration, and in life, I voice out the stories of our four-legged furry friends. Providing a prospect of a good life filled with equal opportunities to students and our pawsome buddies helps me sleep better at night. And for those rainy evenings, I turn to my colors.

TAGS
Engineering
Updated On: 30 Dec'24, 12:10 PM IST