HTTP status codes

Every common HTTP status code in plain English. Search by number or name.

48 status codes

CodeNameMeaning
1xx Informational
100ContinueThe server got the request headers; the client can send the body.
101Switching ProtocolsThe server is switching protocols as requested, for example upgrading to WebSocket.
103Early HintsPreliminary headers (often Link preload hints) sent before the final response.
2xx Success
200OKThe request succeeded.
201CreatedThe request succeeded and a new resource was created, usually after POST or PUT.
202AcceptedThe request was accepted for processing, but the work is not finished yet.
204No ContentSuccess, with no response body. Common for DELETE and some PUT requests.
206Partial ContentOnly part of the resource was sent, in response to a Range header (used for video streaming and resumable downloads).
3xx Redirection
301Moved PermanentlyThe resource has a new permanent URL. Browsers and search engines update to the new address.
302FoundA temporary redirect. Clients should keep using the original URL in future.
303See OtherRedirect to another URL with GET, typically after a form POST.
304Not ModifiedThe cached copy is still valid, so no body is sent. Saves bandwidth.
307Temporary RedirectTemporary redirect that keeps the original method and body (unlike 302 in practice).
308Permanent RedirectPermanent redirect that keeps the original method and body.
4xx Client error
400Bad RequestThe server could not understand the request: malformed syntax, invalid JSON or bad parameters.
401UnauthorizedAuthentication is required or failed. Despite the name, it means "unauthenticated".
402Payment RequiredReserved for future use; some APIs use it when a payment or plan upgrade is needed.
403ForbiddenThe server understood the request but refuses it, often because you lack permission.
404Not FoundNo resource exists at this URL.
405Method Not AllowedThe URL exists but does not support this HTTP method, such as POST to a read-only endpoint.
406Not AcceptableThe server cannot produce a response matching the Accept headers.
408Request TimeoutThe server gave up waiting for the client to finish sending the request.
409ConflictThe request conflicts with the current state, such as an edit conflict or duplicate record.
410GoneThe resource was deliberately removed and will not come back.
411Length RequiredThe server requires a Content-Length header.
412Precondition FailedA condition in the request headers (such as If-Match) was not met.
413Content Too LargeThe request body is bigger than the server allows, such as an upload over the size limit.
414URI Too LongThe URL is longer than the server will process.
415Unsupported Media TypeThe request body format (Content-Type) is not supported.
416Range Not SatisfiableThe requested byte range is outside the size of the resource.
418I'm a teapotAn April Fools joke from RFC 2324, kept alive by developers. Some sites use it to refuse bots.
421Misdirected RequestThe request went to a server that cannot produce a response for this host.
422Unprocessable ContentThe request was well-formed but has semantic errors, such as failed validation.
425Too EarlyThe server is unwilling to process a request that might be replayed.
426Upgrade RequiredThe server refuses the request over the current protocol; its Upgrade header names the one to switch to.
428Precondition RequiredThe server requires the request to be conditional, to prevent lost updates.
429Too Many RequestsRate limited: the client sent too many requests in a given time. Check the Retry-After header.
431Request Header Fields Too LargeThe headers (often cookies) are too large.
451Unavailable For Legal ReasonsThe resource is blocked for legal reasons, such as a court order.
5xx Server error
500Internal Server ErrorA generic server error: something unexpected went wrong.
501Not ImplementedThe server does not support the functionality needed for this request.
502Bad GatewayA gateway or proxy got an invalid response from the server behind it.
503Service UnavailableThe server is temporarily unable to handle the request: overloaded or down for maintenance.
504Gateway TimeoutA gateway or proxy did not get a response in time from the server behind it.
505HTTP Version Not SupportedThe server does not support the HTTP version used.
507Insufficient StorageThe server cannot store what is needed to complete the request (WebDAV).
508Loop DetectedThe server detected an infinite loop while processing (WebDAV).
511Network Authentication RequiredYou need to sign in to the network, such as a hotel or airport Wi-Fi login page.

This tool runs in your browser. We never send what you type or paste to a server.

The five classes

  • 1xx informational: the request was received and is continuing.
  • 2xx success: the request worked.
  • 3xx redirection: the client needs to go somewhere else.
  • 4xx client error: something is wrong with the request (bad URL, no permission, too many requests).
  • 5xx server error: the server failed to handle a valid request.

Codes that matter for SEO

  • 301 vs 302: use 301 (or 308) for permanent moves so search engines transfer ranking to the new URL.
  • 404 vs 410: both remove a page from results. 410 states that the removal is deliberate and permanent.
  • 503 during maintenance tells crawlers to come back later instead of dropping pages. Add a Retry-After header.
  • "Soft 404s", which are error pages returning 200, waste crawl budget. Return a real 404.

Getting a 5xx error or a timeout?

A 500, 502, 503 or 504 from someone else's website usually means their server is struggling, not that something is wrong on your side. To see whether a site is down for everyone or just you, check it from an outside server with Site Down Right Now's website checker. If it's a 502 specifically, their guide to fixing 502 Bad Gateway errors covers both visitors and site owners.

Seeing the status code

The quickest check is from the command line. -I sends a HEAD request and prints only the headers; the first line holds the code.

curl -I https://example.com/                    # status line and headers
curl -sIL https://example.com/old-page          # follow redirects, print every hop
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/   # just the number

(Needs network access, so not run on this page.) Some servers answer HEAD differently from GET, or reject it with 405; drop -I and add -D - to see the headers of a real GET. In the browser, open the developer tools (F12), choose the Network tab and reload: the Status column shows each request's code, and ticking "Preserve log" keeps redirect hops that would otherwise disappear.

In code, remember that fetch treats every completed response as success and only rejects on network failure, so check res.ok (true for 200 to 299) or res.status yourself:

const res = await fetch(`${base}/missing`);
console.log(res.status, res.ok, res.statusText);        // → 404 false Not Found   fetch does not throw on 4xx or 5xx
const r = await fetch(`${base}/old`, { redirect: 'manual' });
console.log(r.status, r.headers.get('location'));       // → 301 /new   Node only; browsers hide manual redirects

Python's urllib does the opposite and raises HTTPError for any 4xx or 5xx. With the third-party requests library you read r.status_code and call r.raise_for_status() when you want an exception; it follows redirects for GET by default, and r.history lists the 301s and 302s it went through.

with urllib.request.urlopen(base + '/') as r:
    print(r.status)                        # → 200
try:
    urllib.request.urlopen(base + '/missing')
except urllib.error.HTTPError as e:        # urllib raises on 4xx and 5xx
    print(e.code, e.reason)                # → 404 Not Found

Both languages also have the standard reason phrases built in. Treat them as labels only: clients and servers act on the number, and the phrase can differ between libraries and versions of the specification (413 used to be "Payload Too Large" and is now "Content Too Large").

print(HTTPStatus(503).phrase)              # → Service Unavailable
print(HTTPStatus.TOO_MANY_REQUESTS.value)  # → 429

Which responses can be cached

A cache stores any response that has explicit freshness, such as Cache-Control: max-age=3600. Without that, RFC 9110 allows caches to guess a lifetime only for 200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414 and 501. Two consequences:

  • A 301 or 308 can be remembered by browsers for a long time, so a wrong permanent redirect is hard to take back. Test with 302 or 307 first.
  • A 404 can be cached too. If a page briefly returned 404 during a deploy, a CDN may keep serving it; send Cache-Control: no-store on error pages you do not want kept, or purge the CDN.

302, 307, 4xx codes such as 401, 403 and 429, and most 5xx responses are only cached when headers say so. 304 Not Modified is not a cached response but the answer to a conditional request (If-None-Match or If-Modified-Since) telling the client its stored copy is still good.

Which errors are worth retrying

A retry only helps when the failure is temporary and repeating the request is safe:

  • Usually retry: 408, 429, 502, 503, 504, and connection resets or timeouts. If the response has a Retry-After header (seconds, or an HTTP date), wait at least that long. Otherwise back off exponentially with some random jitter, so many clients do not retry in step.
  • Retry with care: 500. It may be a passing fault or a bug that fails every time; cap the attempts.
  • Do not retry unchanged: 400, 401, 403, 404, 405, 409, 410, 413, 415 and 422. The same request gets the same answer until you fix it, refresh the credentials or change the data.

The method matters as much as the code. GET, HEAD, OPTIONS, PUT and DELETE are idempotent, so sending them twice has the same effect as once. A POST that timed out may already have created the order or sent the email; retry it only if the API supports an idempotency key or you can check first.

Questions

What is the difference between 401 and 403?

401 means you're not authenticated (log in and try again). 403 means you're authenticated, or it doesn't matter, but you're not allowed.

Is a website down if it returns a 4xx code?

Not necessarily. 4xx means the server is up and rejecting the request. 5xx codes and timeouts usually mean a real outage.

Should an API return 400 or 422 for invalid input?

Use 400 when the request itself is malformed, such as broken JSON, and 422 when it is well formed but fails validation, such as a missing required field. Either is acceptable as long as your API is consistent.

How do I check the status code of a URL?

Run curl -I followed by the URL and read the first line, or open the browser developer tools, go to the Network tab and reload the page. In JavaScript read response.status after fetch; in Python read the status attribute, or catch HTTPError, which urllib raises for 4xx and 5xx codes.

Does fetch throw an error on a 404 or 500?

No. fetch only rejects when no response arrives at all, such as a network failure or a blocked CORS request. A 404 or 500 resolves normally, with response.ok set to false, so check it before reading the body.

Which HTTP status codes should a client retry?

408, 429, 502, 503 and 504 are the usual ones, along with connection errors, honouring Retry-After when it is sent. Retry non-idempotent requests such as POST only when the API gives you a way to avoid doing the work twice, and do not retry other 4xx codes without changing the request.