Guides हि
Bramhify Pro

Unlock advanced tools, unlimited usage, and priority support.

Upgrade Now
Article · (Updated: Nov 18, 2026) · 6 min read

HTTP Status Codes Cheat Sheet: 200, 301, 401 vs 403, 502

Every REST API design review and production incident eventually boils down to a 3-digit HTTP status code. Return 200 OK on an error payload and monitoring dashboards stay falsely green; confuse 401 Unauthorized with 403 Forbidden and your frontend auto-refresh token loop spirals into an infinite redirect; confuse 301 with 302 and Google drops your canonical page from search results.

Bramhify's 100% offline HTTP Status Code Reference lets you search and filter every RFC-standard 1xx, 2xx, 3xx, 4xx, and 5xx response code in milliseconds—with plain-English causes, REST semantics, and developer handling examples right inside your browser.

The 5 HTTP Status Code Classes at a Glance

ClassCategoryWho Is Responsible?Core Meaning
1xxInformationalProtocol / ServerRequest headers received; keep waiting or switch protocol (101 WebSockets)
2xxSuccessAll GoodRequest received, understood, and fulfilled cleanly (200, 201, 204)
3xxRedirectionClient / CacheResource moved or cached copy is still fresh (301, 302, 304, 307, 308)
4xxClient ErrorCaller / FrontendBad input, missing auth, wrong URL, or rate-limited — retrying unchanged won't fix it (400, 401, 403, 404, 422, 429)
5xxServer ErrorBackend / InfraUpstream crashed, timed out, or overloaded — safe to retry with backoff (500, 502, 503, 504)

Search & Filter All RFC HTTP Status Codes Locally:

Bramhify HTTP Status Code Reference showing live search and category filter across 1xx-5xx codes Bramhify HTTP Status Code Reference showing live search and category filter across 1xx-5xx codes
Filter by 1xx–5xx class or search any status number or keyword instantly—100% locally in your browser.
HTTP Status Codes Icon
HTTP Status Code Reference Instant Search · 1xx–5xx · Debugging Tips

The 5 Most Confused Status Code Pairs (Production Rules)

1. 401 Unauthorized vs. 403 Forbidden

Despite the historical name "Unauthorized," RFC 9110 defines 401 strictly as Unauthenticated ("Who are you?"):

  • Return 401 Unauthorized when the Authorization: Bearer ... header is missing, malformed, or the JWT has expired. Client action: refresh token or redirect to /login.
  • Return 403 Forbidden when the server knows who the user is, and their role/tenant explicitly lacks permission (e.g., a standard user calling DELETE /admin/users/42). Client action: show "Access Denied"—do NOT retry login.

2. 301 Moved Permanently vs. 302 Found vs. 307 / 308

  • 301 (Permanent) & 302 (Temporary): Classic browser redirects for GET pages (SEO link equity passes cleanly on 301). However, browsers historically changed a POST request into a GET when following 301/302!
  • 307 Temporary Redirect & 308 Permanent Redirect: Modern RFC equivalents that strictly preserve the HTTP method and request body (POST stays POST)—essential for API endpoint migrations and webhooks.

3. 200 OK vs. 201 Created vs. 202 Accepted vs. 204 No Content

  • 200 OK: Standard synchronous read (GET) or update (PUT/PATCH) returning a response body.
  • 201 Created: New resource created (POST /orders), ideally paired with a Location: /orders/ord_991 header.
  • 202 Accepted: Queued asynchronously (e.g., video transcode job or report export)—processing has not finished yet.
  • 204 No Content: Succeeded with zero response body (ideal for DELETE /items/5 or CORS OPTIONS preflight).

4. 400 Bad Request vs. 422 Unprocessable Content vs. 409 Conflict

  • 400 Bad Request: Malformed syntax—broken JSON, invalid base64, or missing required query parameter.
  • 422 Unprocessable Content: Valid JSON syntax, but domain/schema validation failed (e.g., age: -5 or invalid email format).
  • 409 Conflict: Request conflicts with current server state (e.g., duplicate email signup or optimistic-locking version mismatch).

5. 502 Bad Gateway vs. 503 Service Unavailable vs. 504 Gateway Timeout

When Nginx, Cloudflare, or an AWS ALB sits in front of your app server, these three 5xx codes immediately isolate where the outage lives:

  • 502 Bad Gateway: The reverse proxy connected to your upstream backend (Node/Python/PHP-FPM), and the backend crashed, returned garbage, or refused the connection (ECONNREFUSED).
  • 503 Service Unavailable: Server is alive but intentionally shedding load, in maintenance mode, or zero healthy pods are ready—honors Retry-After header.
  • 504 Gateway Timeout: Your upstream app accepted the connection but failed to finish responding before the proxy timeout (e.g., Nginx's default 60s proxy_read_timeout hit by an unindexed SQL query).

Handling 429 Too Many Requests Cleanly in Frontend & Backend Code

Rate-limiting gateways return 429 Too Many Requests alongside a Retry-After header (in seconds or HTTP date). Never hammer a 429 endpoint in a tight loop—respect Retry-After with exponential backoff + jitter:

async function fetchWithRetry(url, opts = {}, maxAttempts = 3) {
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    const res = await fetch(url, opts);
    if (res.status !== 429 && res.status < 500) return res;

    const retryAfter = Number(res.headers.get('Retry-After'));
    const delayMs = retryAfter > 0
      ? retryAfter * 1000
      : Math.min(1000 * 2 ** (attempt - 1), 8000) + Math.random() * 250;

    if (attempt === maxAttempts) return res;
    await new Promise(r => setTimeout(r, delayMs));
  }
}

Frequently Asked Questions (FAQs)

What is the real difference between 401 Unauthorized and 403 Forbidden?

401 means not authenticated (missing, invalid, or expired credentials—logging in can solve it). 403 means authenticated but not permitted (your account lacks privileges for that resource, so re-authenticating will not change the outcome).

Should I return 404 or 403 when a user requests another tenant's private record?

In security-sensitive multi-tenant APIs (like GitHub private repos or banking records), returning 404 Not Found instead of 403 prevents attackers from enumerating whether a given ID or username exists in your database.

Why did my API redirect drop my POST JSON body?

Because you returned a 301 or 302 redirect, which HTTP clients commonly rewrite to GET without a body. Use 307 Temporary Redirect or 308 Permanent Redirect whenever redirecting POST, PUT, or PATCH API endpoints.

What causes a 502 Bad Gateway in Nginx + Node.js or PHP-FPM?

A 502 means Nginx could not get a valid HTTP response from the upstream socket—usually because the Node/PM2/PHP-FPM process crashed (OOM kill), restarted mid-request, or is listening on a different port/Unix socket than proxy_pass.

Need to debug cURL calls, JWT 401 expiries, or Unix timestamps offline?

Pair this reference with our Convert cURL to Fetch & Axios Guide, JWT & SD-JWT Decoder Guide, and Unix Epoch Timestamp Guide.

Try it yourself

Look up any HTTP status code instantly.

Open HTTP Status Code Reference →