HTTP Status Code Reference: Diagnose API Errors with a Repeatable Debugging Workflow
HTTPAPIsdebuggingweb developmenttroubleshooting

HTTP Status Code Reference: Diagnose API Errors with a Repeatable Debugging Workflow

WWindows.page Editorial Team
2026-11-30
7 min read

A practical HTTP status code reference with API troubleshooting checklists, retry guidance, and next steps for common 4xx and 5xx errors.

Use this HTTP status code reference to identify whether an API problem belongs to the client, the server, authentication flow, network, or application logic—and to choose the next debugging step without guessing.

Overview

An HTTP response contains more than a status code. The code describes the broad outcome of a request, while the response headers and body usually explain what happened in this particular API. A useful debugging workflow therefore treats the status code as a starting signal, not a complete diagnosis.

The first digit places a response into a general class:

  • 1xx: Informational responses. The request is being processed or additional protocol steps are involved.
  • 2xx: The request was received and handled successfully.
  • 3xx: Redirection or a response that requires the client to follow another location or use cached information.
  • 4xx: The request could not be fulfilled because of something about the request, credentials, permissions, or requested resource.
  • 5xx: The server or an upstream service failed to produce a valid response.

For every unexpected response, record the HTTP method, URL, status, response headers, response body, request identifier, and timing. Remove secrets before sharing logs. A repeatable record makes it easier to compare a successful request with a failed one and to determine whether a problem is reproducible.

Common HTTP status codes

CodeMeaningWhat to check next
100 ContinueThe server received the initial request headers and the client may continue sending the request body.Check client and proxy handling when large uploads or an Expect header are involved.
101 Switching ProtocolsThe server is switching to a protocol requested by the client.Inspect upgrade headers and confirm that both sides support the negotiated protocol.
200 OKThe request succeeded.Validate the response schema, content type, and application-level error fields.
201 CreatedThe request created a resource.Look for the resource location and verify that the returned representation matches the created object.
202 AcceptedThe request was accepted for processing but is not necessarily complete.Find the documented job, polling, callback, or result URL rather than assuming completion.
204 No ContentThe request succeeded and there is no response body.Ensure the client does not try to parse an empty body as JSON.
301/302/307/308The resource or request target is associated with another location.Inspect the Location header. Pay attention to whether the client preserves the method and body across the redirect.
304 Not ModifiedThe cached representation can be used because it has not changed.Review conditional headers such as If-None-Match and If-Modified-Since.
400 Bad RequestThe server cannot process the request as submitted.Check JSON syntax, required fields, parameter names, data types, encoding, and malformed headers.
401 UnauthorizedThe request lacks valid authentication credentials.Check whether the credential is present, unexpired, correctly formatted, and sent to the intended host.
403 ForbiddenThe server understood the request but will not authorize it.Compare the caller's roles, scopes, tenant, resource ownership, and environment.
404 Not FoundThe server cannot find a representation for the requested target.Check the URL, API version, identifier, route, deployment, and whether the resource is intentionally hidden.
405 Method Not AllowedThe target does not support the request method.Inspect the Allow header and confirm the documented method and route.
409 ConflictThe request conflicts with the current state of the resource.Check duplicate identifiers, version conflicts, state transitions, and concurrent updates.
412 Precondition FailedA request condition was not satisfied.Review conditional headers, entity tags, and optimistic-concurrency logic.
413 Content Too LargeThe request body exceeds a permitted size.Check client limits, proxy limits, upload configuration, and whether compression or chunking is supported.
415 Unsupported Media TypeThe server does not support the request body's media type.Set the correct Content-Type and send a body matching that format.
422 Unprocessable ContentThe request format is understood, but its content fails validation or cannot be processed.Read field-level validation details and compare them with the API schema.
429 Too Many RequestsThe client has exceeded a rate or concurrency limit.Honor Retry-After when provided, reduce concurrency, and use bounded exponential backoff.
500 Internal Server ErrorThe server encountered an unexpected condition.Capture the request ID and timestamp, retry only when safe, and inspect server logs or provider status information.
501 Not ImplementedThe server does not support the functionality needed to fulfill the request.Confirm endpoint capabilities, method support, and deployment version.
502 Bad GatewayA gateway or proxy received an invalid response from an upstream server.Separate gateway failure from upstream failure by checking proxy logs, upstream health, and request timing.
503 Service UnavailableThe service is temporarily unable to handle the request.Check maintenance, capacity, health checks, dependencies, and any retry guidance.
504 Gateway TimeoutA gateway did not receive a timely response from an upstream server.Check upstream latency, gateway timeouts, long-running work, and whether asynchronous processing is appropriate.

Checklist by scenario

When the response is 4xx

  1. Replay the exact request with a known tool or captured command. Preserve the method, query string, headers, and body.
  2. Compare the failing request with a successful request. Focus on host, API version, authentication, content type, and identifier values.
  3. Validate the body as the expected format. A JSON formatter and validator can expose trailing characters, incorrect nesting, or invalid syntax.
  4. Read the error body for a machine-readable code, field path, correlation ID, and remediation hint. Do not rely on the status code alone.
  5. Check whether the client is sending an old route, unsupported method, expired credential, or insufficient scope.

When the response is 401 or 403

First distinguish authentication from authorization. A 401 commonly means the server cannot accept the presented credentials; a 403 commonly means the caller is recognized but not permitted to perform the operation. Check the authorization scheme, token audience, issuer, expiry, scopes, and selected environment. A JWT decoder can help inspect token claims, but never paste production secrets or treat decoded claims as proof that a token is valid. Signature and server-side policy still matter.

When the response is 429, 502, 503, or 504

Classify the failure as a capacity, dependency, or timing issue before retrying. Check Retry-After, request duration, proxy logs, upstream health, and whether several endpoints fail at the same time. Retry idempotent operations cautiously with a maximum attempt count and backoff. For writes, use an idempotency mechanism when the API provides one, because a timeout does not prove that the server did not complete the operation.

When the response is 2xx but the result is wrong

A successful transport response can still contain an application error, incomplete asynchronous work, stale data, or an unexpected schema. Confirm the content type, required fields, pagination markers, business status, and freshness headers. For a 202 response, follow the documented status or result workflow instead of treating acceptance as completion.

What to double-check

  • Redirect behavior: Different clients may handle redirects differently, especially when a POST body or authorization header is involved. Log the final URL and each hop in a safe debugging environment.
  • Cache behavior: A 304 response is part of a conditional request flow. Inspect cache-control directives, validators, and whether an intermediary is serving an unexpected representation.
  • Headers: Verify Content-Type, Accept, Authorization, correlation IDs, and any required version or tenant headers. Header names are generally case-insensitive, but their values and formatting are not interchangeable.
  • Time and environment: Compare client time, server time, region, base URL, feature flags, and deployment version. Token expiry and routing mistakes often look like general authentication or not-found errors.
  • Request safety: Redact tokens, cookies, passwords, personal data, and signed URLs before placing a request in an issue, chat, or diagnostic tool.
  • Query readability: If an API failure originates from a database query, format and inspect the SQL separately. The SQL formatter guide offers a practical cleanup workflow.

Common mistakes

Retrying every error. A 400, 401, 403, or 404 usually needs a request correction, not repeated attempts. Blind retries can increase rate limits and obscure the original cause.

Assuming 500 identifies the fault. A server response may be triggered by invalid data, a dependency outage, or a gateway configuration problem. Use the request ID and server-side logs to locate the failing boundary.

Confusing 401 with 403. Refreshing a token will not fix a missing permission, and granting permissions will not fix a malformed or expired credential.

Ignoring the response body. Many APIs place the useful field name, validation rule, or retry interval in a structured error object. Preserve it alongside the status code.

Logging sensitive requests. Full headers and bodies can expose credentials. Build redaction into debugging scripts and observability pipelines before an incident occurs.

Parsing every response as JSON. Error pages, empty 204 responses, proxy-generated messages, and plain-text diagnostics may not match the success schema. Check the status and content type first.

When to revisit

Return to this checklist whenever an API provider changes its version, authentication model, rate limits, proxy layer, or error schema. Revisit it before seasonal planning cycles or expected traffic increases, when workflows or tools change, and after moving an integration to a new region or hosting environment.

Make the workflow operational by keeping a small test matrix for expected success, validation failure, missing authentication, forbidden access, rate limiting, timeout, and dependency failure. Record the expected status, safe retry behavior, and alerting threshold for each case. During an incident, begin with one captured request and trace it through the client, gateway, API, and downstream dependency. Afterward, update the matrix with the actual status code, evidence that resolved the issue, and any new redaction or retry rule. That turns an HTTP status code reference into a maintained developer productivity tool rather than a list consulted only after a failure.

Related Topics

#HTTP#APIs#debugging#web development#troubleshooting
W

Windows.page Editorial Team

Developer Resources Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.