The five families

HTTP status codes are grouped by their first digit:

  • 1xx — Informational: Request received, continuing process. Rarely seen in practice.
  • 2xx — Success: The request was successfully received, understood, and accepted.
  • 3xx — Redirection: Further action needed to complete the request.
  • 4xx — Client error: The request contained bad syntax or cannot be fulfilled.
  • 5xx — Server error: The server failed to fulfill a valid request.

2xx — Success codes

CodeNameWhen it's used
200OKStandard success — GET and POST responses
201CreatedPOST created a new resource (e.g., new user, new post)
204No ContentSuccess but no response body — DELETE, some PUTs
206Partial ContentRange request — video streaming, resumable downloads

3xx — Redirects (and why 301 vs 302 matters)

CodeNameSEO/behavior
301Moved PermanentlyGoogle transfers most link equity. Browser caches the redirect.
302Found (Temporary)Google keeps original URL indexed. Link equity not transferred.
307Temporary RedirectLike 302 but preserves HTTP method (POST stays POST)
308Permanent RedirectLike 301 but preserves HTTP method

The 301 vs 302 SEO rule:Use 301 when you've permanently moved a URL — Google will update its index and transfer PageRank. Use 302 for temporary redirects (A/B tests, maintenance pages, login redirects). Using 302 when you mean 301 causes Google to keep indexing the old URL indefinitely.

The 301 browser cache problem: 301s are cached aggressively by browsers. If you redirect A → B using 301 and later need A to go somewhere else, users who visited before will see the cached old redirect until they clear their cache. Use 302 during testing; switch to 301 when permanent.

4xx — Client errors

CodeNameWhen it occurs
400Bad RequestMalformed request syntax — bad JSON body, missing required field
401UnauthorizedNot authenticated — no token or invalid token
403ForbiddenAuthenticated but not authorized — wrong role, wrong permissions
404Not FoundResource doesn't exist at this URL
405Method Not AllowedPOST to a GET-only endpoint
409ConflictResource conflict — duplicate email, version mismatch
410GoneResource permanently deleted — tells Google to deindex faster
422Unprocessable EntityRequest is syntactically valid but semantically invalid
429Too Many RequestsRate limit exceeded — API throttling

401 vs 403:401 means "you need to log in." 403 means "you are logged in but not allowed." Returning 403 for unauthenticated users reveals that a resource exists — some APIs return 404 for security-sensitive resources even when the issue is authentication.

404 vs 410 for SEO:404 tells Google "this page isn't found — try again later." 410 tells Google "this page is permanently gone — remove it from the index." If you delete a URL permanently, 410 accelerates deindexing compared to 404.

5xx — Server errors

CodeNameTypical cause
500Internal Server ErrorUnhandled exception — check server logs
502Bad GatewayReverse proxy got invalid response from upstream
503Service UnavailableServer overloaded or down for maintenance
504Gateway TimeoutUpstream server didn't respond in time

502 vs 504:Both involve a reverse proxy (nginx, Cloudflare) failing to communicate with an upstream service. 502 means the upstream returned something invalid; 504 means it didn't respond at all (timeout). Both are usually caused by the upstream service crashing or being overloaded — not the proxy itself.

Debugging with JSON in API responses

Most REST APIs include a JSON body with error details alongside the status code. Format any API JSON error response for readability with the free JSON formatter — paste the response body and instantly see the error structure.

Related tools


Written by Achraf A., founder of TheFreeAITools.