HTTP Status Code Reference: Diagnosing 4xx and 5xx Errors

Diagnose 4xx and 5xx HTTP status codes fast with a plain-language reference, step-by-step fix workflow and quick lookup table.

· · 3 minutes · 347 Views · 22 sections
Table of contents
  1. What HTTP Status Codes Tell You About a Failing Request
  2. The 4xx Range: Client-Side Errors
  3. 400 Bad Request
  4. 401 Unauthorized and 403 Forbidden
  5. 404 Not Found
  6. 405 Method Not Allowed and 429 Too Many Requests
  7. How to Diagnose a 4xx or 5xx Error Step by Step
  8. The 5xx Range: Server-Side Errors
  9. 500 Internal Server Error
  10. 502 Bad Gateway and 504 Gateway Timeout
  11. 503 Service Unavailable
  12. 507 Insufficient Storage
  13. What Is the Difference Between 4xx and 5xx Status Codes?
  14. Common Traps When Reading Status Codes
  15. Quick Reference for Common Status Codes
  16. FAQ
  17. Is a 4xx error always the client's fault?
  18. Should I retry a 500 error?
  19. What does 502 Bad Gateway usually indicate?
  20. Can a 429 be avoided?
  21. Do status codes differ between HTTP versions?
  22. Conclusion

What HTTP Status Codes Tell You About a Failing Request

You send a request, and instead of the page or data you expected, you get a number: 403, 404, 500. An HTTP status code reference helps you stop guessing and start fixing. This guide covers the 4xx and 5xx ranges in detail, shows you how to diagnose common failures step by step, and explains what each class of error means for the client and the server.

Status codes are three-digit numbers a server returns with every HTTP response. The first digit tells you who is responsible for the problem. Codes beginning with 4 usually mean the request itself is the issue. Codes beginning with 5 mean the server failed to fulfil a request it otherwise understood.

That split matters because the fix is different in each case. A 4xx error usually needs a change on the client side: a corrected URL, a valid credential, a smaller payload. A 5xx error usually needs a change on the server side: more capacity, a fixed bug, a healthier dependency. Reading the class first saves time before you dig into the specific code.

The 4xx Range: Client-Side Errors

The 4xx range covers requests the server rejected because of something in the request. The server understood what you asked for; it declined to act on it as sent.

400 Bad Request

A 400 means the server could not parse the request at all. Common causes include malformed JSON, a missing required header, or a query string with invalid characters. Check the request body against the expected schema first, then verify your headers. A 400 is often a syntax problem rather than a permissions problem.

401 Unauthorized and 403 Forbidden

These two are frequently confused. A 401 means authentication failed or was never supplied: no token, an expired token, or a token the server does not recognise. A 403 means authentication may have succeeded, but the identity lacks permission for that resource. If you receive a 401, refresh or re-send your credentials. If you receive a 403, the credential is likely valid but under-privileged.

404 Not Found

A 404 means the server has no resource at that path. It can be a typo, a deleted record, or a route that was never registered. On public sites, a well-designed 404 page should tell the visitor what to do next rather than leaving a dead end.

405 Method Not Allowed and 429 Too Many Requests

A 405 means the path exists but does not accept the HTTP method you used. Sending a POST to an endpoint that only accepts GET is a typical trigger. A 429 means you have exceeded a rate limit. The response usually carries a Retry-After header telling you how long to wait before trying again.

  • 400: malformed request, fix the syntax
  • 401: missing or invalid credentials
  • 403: valid identity, insufficient permission
  • 404: no resource at that path
  • 405: wrong HTTP method for the endpoint
  • 429: rate limit exceeded, back off

How to Diagnose a 4xx or 5xx Error Step by Step

Work through these steps in order. Most failures resolve before you reach the end.

  1. Read the full response, not just the number. Status lines, headers and bodies often carry a short explanation. The body frequently names the exact field or parameter at fault.
  2. Check the request method and URL. Confirm the path exists and that the method matches what the endpoint expects. A single trailing slash or a wrong verb can produce a 404 or 405.
  3. Inspect the request headers. Look for a missing Content-Type, an expired Authorization value, or a stale cache header. Header problems account for many 400 and 401 responses.
  4. Validate the request body. Validate the request body against the schema the API documents. Malformed or unexpected fields are a frequent cause of 400 responses.
  5. Reproduce the request in isolation. Strip it down to the minimum set of headers and body fields, then add pieces back until it fails. This separates a genuine server fault from an accidental extra parameter.
  6. Check rate limits and retry behaviour. If you see a 429, read the Retry-After header and add exponential backoff rather than hammering the endpoint.
  7. Compare against a known-good request. If you have a working call to the same service, diff the two. Differences in headers, body or timing often reveal the cause immediately.
  8. Escalate with evidence. For a 5xx you cannot explain, capture the timestamp, the request ID and the exact payload. That record is what a server team needs to trace the fault.

If you need to decode a URL-encoded query string or inspect a response body, a browser-based URL encoder and decoder can help you read the raw values. Nothing leaves your machine, which keeps sensitive parameters out of third-party logs.

The 5xx Range: Server-Side Errors

A 5xx means the server accepted the request but failed while processing it. The request may be entirely valid; the fault sits on the other side.

500 Internal Server Error

A 500 is the catch-all. It tells you the server hit an unhandled condition and could not complete the request. The cause could be a null reference, a failed database query, or an unhandled exception in application code. Without server logs, a 500 gives you little to work with, so capture the timestamp and request ID.

502 Bad Gateway and 504 Gateway Timeout

A 502 means a gateway or proxy received an invalid response from an upstream server. A 504 means the upstream server did not respond within the allowed time. Both point to a problem between the edge and the application, not in your request. Retrying can help with a 504 if the upstream was briefly overloaded; a persistent 502 usually needs intervention on the server side.

503 Service Unavailable

A 503 signals the server is temporarily unable to handle requests, often from maintenance or overload. It frequently includes a Retry-After header. Honouring that header is more effective than immediate retries, which add load to a service already struggling.

507 Insufficient Storage

A 507 means the server cannot store the representation needed to complete the request. It typically indicates a full disk or an exhausted quota on the server side. There is nothing to fix in your request; the operator needs to free capacity.

A 5xx is rarely your fault. Your job is to prove the request was valid, then hand the server team a precise record of what happened.

What Is the Difference Between 4xx and 5xx Status Codes?

A 4xx status code means the client sent a request the server will not process, usually because of a syntax, authentication or permission problem. A 5xx status code means the server received a valid request but failed while handling it. The first digit is the fastest way to tell which side of the connection needs fixing.

Common Traps When Reading Status Codes

A few patterns mislead people again and again.

  • Treating 401 and 403 as the same. They point at different fixes. Refreshing a token will not solve a 403.
  • Retrying a 4xx blindly. Retries help with 429 and some 5xx responses. They will never fix a malformed request.
  • Ignoring the response body. Many APIs return a structured error with a code and message. Reading it often answers the question outright.
  • Assuming 404 means deleted. A route may never have existed, or a proxy may be rewriting the path.
  • Missing the Retry-After header. Backing off correctly is faster than retrying at full speed.

Quick Reference for Common Status Codes

CodeMeaningTypical fix
400Bad RequestCorrect the request syntax or body
401UnauthorizedSupply or refresh credentials
403ForbiddenRequest access with a privileged identity
404Not FoundVerify the path or resource ID
405Method Not AllowedUse the method the endpoint supports
429Too Many RequestsBack off and honour Retry-After
500Internal Server ErrorCapture evidence and escalate
502Bad GatewayCheck the upstream service
503Service UnavailableWait and retry after the stated interval
504Gateway TimeoutRetry, then investigate upstream latency

FAQ

Is a 4xx error always the client's fault?

Mostly, yes. A 4xx means the server understood the request and declined to process it, usually because of a syntax, authentication or permission problem. There are edge cases where a misconfigured server returns a 4xx for a valid request, but the first assumption should be the request itself.

Should I retry a 500 error?

Retry once, then stop. A single retry can clear a transient fault. Repeated retries against a persistent 500 add load and hide the real problem. If the second attempt fails, capture the request ID and escalate rather than looping.

What does 502 Bad Gateway usually indicate?

A 502 means a gateway or proxy received an invalid response from an upstream server. It usually points to a crashed, restarting or unreachable backend rather than a problem with your request. The fix almost always sits with the service operator, not the client.

Can a 429 be avoided?

Yes, in most cases. Read the rate-limit headers the API returns, cache responses where possible, and space out requests. When you do hit a 429, honour the Retry-After value and add exponential backoff instead of retrying immediately.

Do status codes differ between HTTP versions?

The meaning of each code is consistent across versions. What changes is how the connection is managed, not what a 400 or a 503 means. You can rely on the same interpretation regardless of the protocol version in use.

Conclusion

An HTTP status code reference is only useful if it shortens the path from symptom to fix. Read the first digit, then the specific code, then the response body. In most cases you will know within a minute whether the problem is in your request or on the server, and what to do next. Keep this guide open the next time a request fails, and you will spend less time guessing and more time shipping.

347 Views ·

Discover More Online Tools

Free text processing, PDF tools, AI writing and more