HTTP Error Codes: 400, 401, 403, 404, 429 & 500
Find what common HTTP errors mean, what to check in an API response, and when a retry can help. Includes a status-code comparison and debugging steps.
Common HTTP errors at a glance
The code narrows the investigation; it rarely explains the whole cause. An application may provide a useful error message or request identifier in the body or headers. Preserve that context when reporting a problem.
| Code | Meaning | First thing to inspect |
|---|---|---|
| 400 | Bad Request | Request shape and validation details |
| 401 | Unauthorized: authentication is required or failed | Credentials and authentication challenge |
| 403 | Forbidden | Account permissions and access policy |
| 404 | Not Found | Route, resource identifier, and access behavior |
| 409 | Conflict | Current state and conflicting change |
| 422 | Unprocessable Content | Semantically invalid input |
| 429 | Too Many Requests | Rate limits and Retry-After if provided |
| 500 | Internal Server Error | Request identifier and server logs |
| 502 | Bad Gateway | Response from the upstream service |
| 503 | Service Unavailable | Service status and retry guidance |
| 504 | Gateway Timeout | Upstream timeout and request duration |
Inspect the actual request before changing code
Open the browser’s Network panel and reproduce the failing action once. Select the request that failed, then inspect its URL, method, status, response headers, and response body. A page can make several requests; do not assume the first error visible in the console is the underlying cause.
For a command-line request, curl -i includes response headers. The example below uses a public demonstration hostname as a placeholder; replace it with your own test endpoint. Keep credentials out of copied commands, screenshots, and public issue reports.
curl -i "https://example.com/api/items"401 vs 403 vs 404: different questions
For a 401, check whether the expected authentication was actually sent and whether it is still valid. For a 403, examine which operation the account or app is allowed to perform. Repeatedly signing in may not change a policy that refuses access.
For a 404, compare the requested path and identifier with the API documentation and the environment you intended to call. A development identifier may not exist in production. Some services also avoid disclosing the existence of a protected resource, so a 404 is not universal proof that no such resource exists.
An authorization header can be present yet contain the wrong credential type. A decoded token can help you inspect claims, but decoding alone does not verify its signature or establish that the receiving service accepts it. Use the provider’s documented authentication flow.
When should you retry a failed request?
An unchanged request with a validation error is unlikely to improve on retry. For a rate limit or temporary service problem, read the provider’s retry guidance and honor Retry-After when it is supplied. Add a maximum number of attempts rather than retrying forever.
Before retrying a write, determine whether the first operation may already have succeeded. A connection failure after a payment or job submission can leave the outcome uncertain. Use the service’s documented idempotency mechanism or query the operation’s status instead of creating a duplicate.
Treat retries as a response to an understood failure mode. Record how many attempts occurred and what finally happened. That evidence is more useful than a generic message saying the request failed, especially when a temporary problem later disappears.
Why an HTTP error can also become a JSON parse error
An API client might expect JSON but receive an HTML error page from a proxy or hosting service. Calling a JSON parser on that page can produce an “Unexpected token” error that obscures the original HTTP status. Check status and Content-Type before deciding how to parse the response.
If the body is JSON, use the formatter to inspect a non-sensitive sample. Formatting helps reveal error fields and nested details; it does not fix the failed request or verify the server’s explanation. Keep the original status alongside the formatted body in your debugging notes.
Frequently asked questions
Does a 500 error mean my internet connection is broken?
It indicates that the responding server encountered an internal failure. The code alone does not identify which component failed. Compare the service status, request identifier, and reproducibility before drawing a conclusion.
Will clearing cookies fix a 403?
It may change a browser session, but it does not grant a permission the account lacks. Inspect the service’s error details and access policy before deleting browser data.
References
Check the official documentation for command options and runtime-specific behavior.
Integrated Tools & Learning Resources
DevX Tool combines deep engineering tutorials with client-side interactive tooling so you can test code, verify outputs, and troubleshoot bugs right away.
Related tutorials and articles
JSON vs YAML vs TOML: Which Configuration Format Fits?
Compare JSON, YAML, and TOML using the same configuration example. Understand comments, indentation, data types, and safe conversion between formats.
Read article Everyday Developer TasksHow to Open and Format a JSON File
Open JSON files on Windows, Mac, or Linux, format them in a browser or terminal, and fix common validation errors with practical examples.
Read article Web Standards & DebuggingFix Expected Double-Quoted Property Name in JSON
Diagnose and resolve 'Expected double-quoted property name in JSON' errors. Learn how ECMA-404 differs from Python dicts and JS objects with automated regex and AST fixes.
Read article AI & LLM ArchitectureFix Invalid JSON Schema Errors in Structured Outputs
Fix Structured Outputs schema errors: additionalProperties, required fields, and Pydantic or Zod definitions. Includes JSON Schema debugging examples.
Read article