DevToolsHub
โ† Back to Home
Cheat Sheet

HTTP Status Codes Cheat Sheet

June 24, 20268 min read

Every web developer encounters HTTP status codes daily. From successful 200 OK responses to mysterious 418 I'm a Teapot โ€” understanding what each code means is essential for debugging APIs, configuring servers, and building robust applications.

This cheat sheet covers every standard HTTP status code from 100 to 511, grouped by category. Use it as a quick reference whenever you encounter an unfamiliar response code.

๐Ÿ” Quick Tip

Use our JSON Formatter to prettify API error responses, and our Base64 Encoder/Decoder to decode token-based auth errors.

1xx Informational Responses

These codes indicate that the server has received the request headers and the client should continue sending the request body. They are provisional responses โ€” the client should wait for a final response.

CodeNameDescription
100ContinueServer received headers, client should send body
101Switching ProtocolsServer is switching to the protocol requested in Upgrade header (e.g., WebSocket)
102ProcessingServer has received and is processing request, but no response yet (WebDAV)
103Early HintsServer can send some response headers before final response (for preloading)

2xx Success Responses

The request was successfully received, understood, and accepted. These are the codes every developer loves to see.

CodeNameDescription
200OKStandard success response for GET, PUT, PATCH, and POST requests
201CreatedResource was successfully created (typically after POST/PUT). Include Location header
202AcceptedRequest accepted but not yet processed (async processing)
203Non-Authoritative InfoReturned metadata is from a third-party copy, not the origin server
204No ContentRequest succeeded but no content to return (DELETE, or PUT saving unchanged data)
205Reset ContentServer fulfilled request, user agent should reset the document view
206Partial ContentServer is delivering only part of the resource (range requests, video streaming)
207Multi-StatusMultiple status codes for multiple operations (WebDAV)
208Already ReportedMembers of a DAV binding have already been enumerated (WebDAV)
226IM UsedServer fulfilled GET request using instance manipulations

3xx Redirection Responses

The client must take additional action to complete the request. Usually means the resource has moved or the request needs different treatment.

CodeNameDescription
300Multiple ChoicesMultiple possible representations; user or agent should choose one
301Moved PermanentlyResource permanently moved to new URL. Browsers cache this redirect. Update bookmarks
302FoundResource temporarily found at different URI. Use for temporary redirects
303See OtherResponse to POST can be found at another URI (use GET to retrieve)
304Not ModifiedCached version is still valid (conditional GET using If-Modified-Since / ETag)
305Use ProxyRequested resource must be accessed through a proxy (deprecated)
306Switch ProxyNo longer used. Originally meant "subsequent requests should use specified proxy"
307Temporary RedirectLike 302 but guarantees method and body won't change when following redirect
308Permanent RedirectLike 301 but guarantees method and body won't change when following redirect

4xx Client Error Responses

The request contains bad syntax or cannot be fulfilled. These are the most common errors you'll encounter while debugging APIs.

CodeNameDescription
400Bad RequestMalformed request syntax, invalid message framing, or deceptive request routing
401UnauthorizedAuthentication is required or has failed. Include WWW-Authenticate header
402Payment RequiredReserved for future use (digital payment systems). Rarely used in practice
403ForbiddenServer understood the request but refuses to authorize it. Different from 401
404Not FoundServer cannot find the requested resource. The most famous HTTP error
405Method Not AllowedHTTP method not supported for this resource. Include Allow header
406Not AcceptableResource cannot produce content matching Accept headers
407Proxy Auth RequiredClient must first authenticate with the proxy (like 401 for proxies)
408Request TimeoutServer timed out waiting for the request. Client can re-send
409ConflictRequest conflicts with current state of the resource (e.g., version conflicts)
410GoneResource is gone and will not be available again. Unlike 404, this is permanent
411Length RequiredContent-Length header is required but was not provided
412Precondition FailedConditional request headers (If-Match, If-None-Match) evaluated to false
413Payload Too LargeRequest entity is larger than server is willing or able to process
414URI Too LongURI requested is longer than server can interpret
415Unsupported Media TypeMedia format in Content-Type is not supported by the server
416Range Not SatisfiableRange specified in Range header cannot be fulfilled
417Expectation FailedServer cannot meet the requirements of the Expect request header
418I'm a TeapotApril Fools' joke (HTCPCP). Some servers use it for blocking bot traffic
421Misdirected RequestRequest was directed at a server that cannot produce a response
422Unprocessable EntityRequest body is syntactically correct but semantically invalid (validation errors)
423LockedResource is locked (WebDAV)
424Failed DependencyRequest failed because another request it depended on failed (WebDAV)
425Too EarlyServer is unwilling to process a request that might be replayed
426Upgrade RequiredClient should switch to a different protocol (e.g., HTTP/1.1 โ†’ HTTP/2)
428Precondition RequiredServer requires the request to be conditional (prevent lost updates)
429Too Many RequestsRate limit exceeded. Include Retry-After header. Very common in APIs
431Header Fields Too LargeRequest header fields are too large (individual header or total size)
451Unavailable For Legal ReasonsResource blocked due to legal demands (censorship, copyright takedowns)

5xx Server Error Responses

The server failed to fulfill a valid request. These indicate problems on the server side โ€” but sometimes the real issue is upstream.

CodeNameDescription
500Internal Server ErrorGeneric server error when no specific message fits. Check server logs
501Not ImplementedServer does not support the HTTP method. Unlike 405, this means server can't handle it at all
502Bad GatewayServer acting as gateway got an invalid response from upstream server
503Service UnavailableServer temporarily overloaded or under maintenance. Include Retry-After header
504Gateway TimeoutServer acting as gateway did not receive response from upstream in time
505HTTP Version Not SupportedServer does not support the HTTP protocol version used in the request
506Variant Also NegotiatesServer configuration error: circular reference in transparent content negotiation
507Insufficient StorageServer cannot store the representation needed to complete the request (WebDAV)
508Loop DetectedServer detected an infinite loop processing the request (WebDAV)
510Not ExtendedFurther extensions to the request are required for the server to fulfill it
511Network Auth RequiredClient needs to authenticate to gain network access (captive portals)

Quick Reference by Category

Some status codes appear in unexpected places. Here's a breakdown of which codes are commonly seen in specific scenarios:

ScenarioCommon Codes
REST API - GET200 (OK), 404 (Not Found), 401 (Unauthorized)
REST API - POST201 (Created), 400 (Bad Request), 422 (Unprocessable Entity), 409 (Conflict)
REST API - PUT/PATCH200 (OK), 204 (No Content), 409 (Conflict), 412 (Precondition Failed)
REST API - DELETE204 (No Content), 404 (Not Found), 410 (Gone)
CDN / Proxy502 (Bad Gateway), 504 (Gateway Timeout), 301 (Moved Permanently)
Rate Limiting429 (Too Many Requests), 503 (Service Unavailable)
Auth / Tokens401 (Unauthorized), 403 (Forbidden), 407 (Proxy Auth Required)
File Upload413 (Payload Too Large), 415 (Unsupported Media Type)
Redirects301 (Permanent), 302 (Temporary), 307 (Temporary, method-preserving), 308 (Permanent, method-preserving)

Common Mistakes & Best Practices

1. Don't Use 200 for Everything

Many poorly designed APIs return 200 OK for everything, including errors, and handle them in the response body. This breaks HTTP semantics and makes debugging harder. Use the correct status code for each scenario.

2. 401 vs 403 โ€” Know the Difference

401 Unauthorized means the client is not authenticated (no valid credentials). 403 Forbidden means the client is authenticated but lacks permission. Use them correctly โ€” a logged-in user hitting an admin endpoint should get 403, not 401.

3. Always Return Proper Error Bodies

When returning 4xx or 5xx, include a structured error response body:

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Email is required",
    "details": [
      { "field": "email", "issue": "must not be empty" }
    ]
  }
}

4. Use Retry-After With 429 and 503

When rate-limiting (429) or serving maintenance pages (503), include the Retry-After header so clients know when to retry. This prevents thundering herd problems.

5. 301 Redirects Are Cached by Browsers

A 301 Moved Permanentlyredirect is aggressively cached by browsers. If you accidentally serve a 301 to the wrong URL, clients will cache it and you'll have trouble fixing it. Use 302 or 307 for temporary redirects.

๐ŸŽฏ Quick Summary

  • 1xx โ€” Informational: continue, switching protocols
  • 2xx โ€” Success: everything worked as expected
  • 3xx โ€” Redirection: resource moved, use different URL
  • 4xx โ€” Client Error: bad request, auth failure, not found (debug here first)
  • 5xx โ€” Server Error: server crashed, gateway timeout, overloaded
  • Use our JSON Formatter to read API error responses

Frequently Asked Questions

What is the difference between 401 Unauthorized and 403 Forbidden?
401 Unauthorized means the client is not authenticated โ€” no valid credentials were provided, or the token is missing or expired. 403 Forbidden means the client is authenticated but does not have permission to access the resource. A logged-in user hitting an admin endpoint should get 403; an anonymous request should get 401. Also note that the spec recommends 401 include a WWW-Authenticate header describing the auth scheme.
What is the difference between 301, 302, 307, and 308 redirects?
301 and 308 are permanent redirects; 302 and 307 are temporary. The key difference is method handling: 301 and 302 may rewrite POST into GET (most browsers do), while 307 and 308 always preserve the method and request body. Use 308 for permanent redirects of form submissions or API endpoints, and 307 for temporary ones where the method must survive.
When should I return 429 Too Many Requests?
Return 429 when a client exceeds your rate limit โ€” for example, more than 100 requests per minute. Always include a Retry-After header (in seconds or an HTTP date) so clients know when to try again, and consider adding RateLimit-Limit, RateLimit-Remaining, and RateLimit-Reset headers for transparency. Use 503 instead when the whole service is overloaded or down for maintenance, since that signals a server-side condition rather than a client quota.
Should I return 404 or 403 for resources that exist but are not authorized?
For security-sensitive resources, returning 404 is usually the better choice. A 403 tells an attacker that the resource exists, letting them enumerate your API. Returning 404 for both "not found" and "forbidden" hides the resource's existence. Reserve 403 for cases where revealing existence is fine, such as a public site telling a logged-in user they lack admin rights.
What is the difference between 500, 502, 503, and 504?
500 Internal Server Error is a generic failure inside your application โ€” an unhandled exception or misconfiguration. 502 Bad Gateway means an upstream server (like a reverse proxy's backend) returned an invalid response. 503 Service Unavailable means the server is overloaded or in maintenance โ€” pair it with Retry-After. 504 Gateway Timeout means an upstream server didn't respond in time. All four are server-side: check your application logs, upstream health, and load balancer configuration in that order.