Development

HTTP Status Lookup

Look up HTTP status codes and their meanings. Quick reference for developers.

Advertisement

Why HTTP Status Codes Matter

HTTP status codes are three-digit numbers returned by a server in response to a client request, indicating the outcome of the request. They are a fundamental part of the HTTP protocol, standardized in RFC 9110, and they communicate to clients — whether browsers, mobile apps, or other services — what happened when the request was processed. Choosing the correct status code is a core skill for any developer building web APIs or applications.

Status codes matter because they enable clients to react appropriately to responses without parsing the response body. A 404 tells a browser to show a "page not found" message; a 401 tells an API client to refresh its authentication token; a 429 tells a client to back off and retry with exponential delay. These behaviors are encoded in HTTP client libraries, frameworks, and infrastructure (proxies, load balancers, CDNs), so using the correct code ensures your service integrates correctly with the broader web ecosystem.

In API design, status codes are part of your contract with clients. Consistent, correct use of status codes makes your API predictable and easy to integrate with. Inconsistent or incorrect use — returning 200 for errors, 404 for unauthorized access, or 500 for validation failures — forces clients to parse response bodies to determine success, breaking the HTTP contract and making integrations fragile.

  • Three-digit numbers indicating the outcome of an HTTP request
  • Standardized in RFC 9110 (formerly RFC 7231 and others)
  • Enable clients to react appropriately without parsing the response body
  • A core part of the API contract between server and client

The Five Status Code Classes

HTTP status codes are divided into five classes, identified by their first digit. The 1xx class (Informational) is rarely used in modern APIs; the most common member is 100 Continue, used during large uploads to confirm the server is willing to accept the request body. The 2xx class (Successful) indicates the request was processed successfully, with 200 OK, 201 Created, and 204 No Content being the most common members.

The 3xx class (Redirection) indicates the client must take additional action to complete the request. The most important members are 301 Moved Permanently (used for permanent URL changes, preserves SEO signals), 302 Found (temporary redirect), 304 Not Modified (used with conditional requests and ETags to avoid re-sending unchanged content), and 307 and 308 which preserve the HTTP method across redirects (unlike 301 and 302, which historically caused method downgrading to GET).

The 4xx class (Client Error) indicates the client made a mistake — the request was malformed, unauthorized, or requested a non-existent resource. Common members include 400 Bad Request (generic client error, used for validation failures and malformed payloads), 401 Unauthorized (missing or invalid authentication), 403 Forbidden (authenticated but not allowed), 404 Not Found (resource does not exist), 409 Conflict (request conflicts with current state), and 429 Too Many Requests (rate limiting).

The 5xx class (Server Error) indicates the server failed to fulfill a valid request. Common members include 500 Internal Server Error (generic server failure), 502 Bad Gateway (upstream service returned an invalid response), 503 Service Unavailable (server temporarily overloaded or under maintenance), and 504 Gateway Timeout (upstream service did not respond in time). 5xx errors typically indicate bugs, infrastructure issues, or capacity problems that require server-side investigation.

  • 1xx Informational — rarely used in modern APIs
  • 2xx Successful — request processed correctly
  • 3xx Redirection — client must take additional action
  • 4xx Client Error — the request was wrong
  • 5xx Server Error — the server failed

Choosing the Right Status Code

Selecting the correct status code requires thinking about what actually happened from the server's perspective. For a successful resource creation, return 201 Created with a Location header pointing to the new resource. For a successful update, return 200 OK with the updated representation, or 204 No Content if you do not return a body. For deletions, 204 No Content is conventional. These choices seem small, but they communicate precise semantics that API clients rely on.

Error responses deserve particular care. Return 400 for validation failures — malformed JSON, missing required fields, invalid field values. Return 401 when authentication is missing or invalid, and 403 when the authenticated user lacks permission for the specific resource. Return 404 when a resource does not exist, but be careful: returning 404 vs 403 for a resource the user cannot access is a security decision. If you return 404 for hidden resources, you avoid confirming their existence to unauthorized users.

For long-running operations, consider 202 Accepted to indicate the request has been queued for processing but not yet completed. For conditional requests, 304 Not Modified saves bandwidth by telling the client their cached copy is still current. For rate limiting, 429 with a Retry-After header tells clients when to try again. Each of these choices improves the robustness of your API contract.

  • 201 Created for new resources, with a Location header
  • 204 No Content for updates or deletions without a body
  • 400 for validation failures and malformed payloads
  • 401 for missing authentication, 403 for insufficient permissions
  • 429 with Retry-After header for rate limiting

Common Mistakes in API Status Code Usage

One of the most pervasive mistakes is returning 200 OK for error responses, with the error details buried in the response body. This breaks the HTTP contract — clients and middleware that check status codes will treat the request as successful, silently swallowing errors. Always use 4xx or 5xx codes for error conditions, even if your response body also contains error details.

Another common mistake is overusing 500 for client errors. A validation failure is not a server error — it is a 400. A missing resource is not a server error — it is a 404. Using 500 for these cases pollutes your error monitoring, hides real server-side failures in noise, and prevents clients from distinguishing recoverable errors from genuine server problems.

Inconsistent status code usage across endpoints is a third common problem. If your create endpoint returns 201 but your update endpoint returns 200, or if one endpoint returns 404 for missing resources while another returns 400, clients must special-case each endpoint. Establish conventions at the API design level and apply them uniformly across all endpoints to make your API predictable.

  • Returning 200 for errors — breaks the HTTP contract
  • Using 500 for client errors — pollutes monitoring and misleads clients
  • Inconsistent codes across endpoints — forces per-endpoint special casing
  • Returning 401 when you mean 403 — authentication vs authorization
  • Forgetting 429 for rate limiting — clients will retry aggressively

Status Codes and SEO

HTTP status codes have a direct impact on search engine optimization. Search crawlers like Googlebot interpret status codes to decide whether to index, re-crawl, or drop pages from the index. Using the wrong code can cause pages to disappear from search results or cause crawlers to waste their budget on duplicate or non-existent content.

A 200 OK tells crawlers the page exists and should be indexed. A 301 Moved Permanently tells crawlers to update their index to the new URL and consolidate ranking signals — this is the correct code for permanent URL changes, domain migrations, and canonicalization of duplicate content. A 302 Found tells crawlers the redirect is temporary and they should keep the old URL in the index, which is usually not what you want for permanent changes.

A 404 Not Found tells crawlers the page is gone, and after repeated 404s the URL will be dropped from the index. A 410 Gone is stronger — it explicitly indicates the resource was removed permanently, which causes faster removal from the index. A 503 Service Unavailable with a Retry-After header tells crawlers the outage is temporary and they should come back later rather than dropping the page — this is the correct code for planned maintenance.

  • 200 OK — page exists and should be indexed
  • 301 Moved Permanently — update the index to the new URL
  • 302 Found — temporary redirect, keep old URL indexed
  • 404 Not Found — page gone, will eventually be deindexed
  • 410 Gone — permanent removal, faster deindexing
  • 503 with Retry-After — temporary outage, do not deindex

Practical Tips for Working with Status Codes

When debugging HTTP APIs, the status code is your first clue. Always log it alongside the request method and path, and set up monitoring to track error rates by status code class. A sudden spike in 5xx codes indicates a server-side problem; a spike in 4xx codes may indicate a client regression or a breaking change in your API. Dashboards that break down responses by status code class make these patterns visible at a glance.

When building API clients, handle status codes explicitly rather than treating anything in the 2xx range as success. A 201 tells you a resource was created and you may need to follow the Location header. A 204 tells you there is no body to parse. A 202 tells you the operation is asynchronous and you may need to poll for completion. Handling these cases specifically makes your client more robust.

For error responses, parse the response body for additional details, but use the status code as the primary signal for retry logic. 429 and 5xx codes are typically retryable (with exponential backoff), while 4xx codes (except 429) are usually not — retrying a 400 or 404 will not help. Libraries that automate this distinction save you from writing repetitive error-handling code.

Finally, document your status code usage in your API specification. OpenAPI and similar specs let you declare which status codes each endpoint can return, along with the response schema for each. This documentation is invaluable for API consumers and serves as a useful review tool for your own design — if an endpoint returns a status code not listed in the spec, that is a bug to investigate.

  • Log status codes and monitor error rates by class
  • Handle 201, 204, and 202 specifically in API clients
  • Retry 429 and 5xx with exponential backoff, not 4xx
  • Document status codes in your OpenAPI specification
  • Use 503 with Retry-After for planned maintenance windows