API & HTTP

HTTP Status Codes

Look up what every HTTP status code means, from 200 OK and 301 redirects to 404, 429 and 503 errors, including common Cloudflare codes.

Guide: HTTP Status Codes: 401 vs 403, 301 vs 302, 502 vs 504

Ready.
CodeNameMeaning
100ContinueThe server received the request headers and the client should send the body.
101Switching ProtocolsThe server is switching protocols as requested, for example to WebSocket.
102Processing WebDAVThe server has accepted the request but has not finished yet (WebDAV).
103Early HintsLets the browser start preloading resources while the server prepares the final response.
200OKThe request succeeded. The response contains the result.
201CreatedThe request succeeded and a new resource was created, usually after POST or PUT.
202AcceptedThe request was accepted for processing, but processing is not complete.
203Non-Authoritative InformationThe response was modified by a transforming proxy.
204No ContentThe request succeeded and there is no body to return.
205Reset ContentThe request succeeded and the client should reset the view that sent it.
206Partial ContentOnly part of the resource is returned, in reply to a Range request.
207Multi-Status WebDAVSeveral separate results are contained in one response (WebDAV).
208Already Reported WebDAVMembers of a binding were already listed earlier in the response (WebDAV).
226IM UsedThe server fulfilled a GET using instance manipulations.
300Multiple ChoicesThere are several possible responses and the client may choose one.
301Moved PermanentlyThe resource has a new permanent URL. Search engines generally treat the new URL as the main address.
302FoundThe resource is temporarily at a different URL. Clients keep using the original URL.
303See OtherFetch the result with a GET at another URL, typically after a POST.
304Not ModifiedThe cached copy is still valid, so no body is sent.
305Use Proxy DeprecatedThe resource must be accessed through a proxy. Deprecated and no longer used.
307Temporary RedirectTemporary redirect that keeps the same HTTP method and body.
308Permanent RedirectPermanent redirect that keeps the same HTTP method and body.
400Bad RequestThe server cannot process the request because of a client error such as malformed syntax.
401UnauthorizedAuthentication is required or has failed. The client has not proven who it is.
402Payment RequiredReserved for future use. Some services use it for billing or quota problems.
403ForbiddenThe server understood the request but refuses to allow it. Logging in again will not help.
404Not FoundThe server cannot find the requested resource.
405Method Not AllowedThe HTTP method is not supported for this resource.
406Not AcceptableThe server cannot produce a response matching the client's Accept headers.
407Proxy Authentication RequiredLike 401, but authentication with a proxy is needed.
408Request TimeoutThe server timed out waiting for the request.
409ConflictThe request conflicts with the current state of the resource, such as an edit conflict.
410GoneThe resource was removed permanently 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 larger than the server allows. Formerly named Payload Too Large.
414URI Too LongThe URL is longer than the server is willing to process.
415Unsupported Media TypeThe request body is in a format the server does not support.
416Range Not SatisfiableThe requested byte range cannot be served.
417Expectation FailedThe server cannot meet the requirements of the Expect header.
418I'm a teapotA joke status from the 1998 April Fools' RFC 2324. Some APIs use it deliberately.
421Misdirected RequestThe request was sent to a server that cannot produce a response for it.
422Unprocessable ContentThe request is well-formed but its content failed validation. Common in APIs.
423Locked WebDAVThe resource is locked (WebDAV).
424Failed Dependency WebDAVThe request failed because an earlier request failed (WebDAV).
425Too EarlyThe server will not risk processing a request that might be replayed.
426Upgrade RequiredThe client must switch to a different protocol, indicated in the Upgrade header.
428Precondition RequiredThe server requires the request to be conditional.
429Too Many RequestsThe client is being rate limited. A Retry-After header may say when to try again.
431Request Header Fields Too LargeThe headers, individually or in total, are too large.
451Unavailable For Legal ReasonsAccess is denied for legal reasons, such as a court order.
500Internal Server ErrorThe server hit an unexpected condition. A generic server-side failure.
501Not ImplementedThe server does not support the functionality required to fulfil the request.
502Bad GatewayA gateway or proxy received an invalid response from the upstream server.
503Service UnavailableThe server is overloaded or down for maintenance. Often temporary.
504Gateway TimeoutA gateway or proxy did not get a response from the upstream server in time.
505HTTP Version Not SupportedThe server does not support the HTTP version used in the request.
506Variant Also NegotiatesA configuration error in content negotiation.
507Insufficient Storage WebDAVThe server cannot store the data needed to complete the request (WebDAV).
508Loop Detected WebDAVThe server detected an infinite loop while processing the request (WebDAV).
510Not ExtendedFurther extensions to the request are required (rarely used).
511Network Authentication RequiredThe client must authenticate to gain network access, as on a captive portal.
520Web Server Returned an Unknown Error CloudflareCloudflare received an empty, unknown or unexpected response from the origin server.
521Web Server Is Down CloudflareCloudflare could not connect because the origin server refused the connection.
522Connection Timed Out CloudflareCloudflare could not complete a TCP connection to the origin server in time.
523Origin Is Unreachable CloudflareCloudflare cannot reach the origin server, for example because of a DNS or routing problem.
524A Timeout Occurred CloudflareCloudflare connected to the origin but did not receive an HTTP response in time.
525SSL Handshake Failed CloudflareThe TLS handshake between Cloudflare and the origin server failed.
526Invalid SSL Certificate CloudflareCloudflare could not validate the origin server's TLS certificate.

What it does

Every HTTP response starts with a three-digit status code that tells the client how the request went. The first digit gives the class: 1xx informational, 2xx success, 3xx redirection, 4xx the client made a mistake, 5xx the server failed.

Codes people often mix up

  • 401 vs 403: 401 means "who are you?" (not authenticated); 403 means "I know who you are, and the answer is no".
  • 301 vs 302: 301 is permanent and 302 is temporary; search engines use the difference as a hint about which URL to keep. 307 and 308 are the same ideas but never change the HTTP method.
  • 502, 503 and 504: a bad response from upstream, an overloaded or offline server, and an upstream that took too long.

Codes 520-526 are not part of the HTTP standard: Cloudflare uses them to describe problems reaching your origin server.

Choosing a code for an API or a page

  • 200, 201, 204: 200 returns a body, 201 says something was created, and 204 succeeds with no body, as after a DELETE.
  • 400 vs 422: 400 is for a request that is malformed, 422 for one that is well formed but fails validation. Many APIs use only 400; what matters is being consistent.
  • 304: the answer to a conditional request, such as one with If-None-Match. The client keeps using its cached copy.
  • 401, 405 and 429: a 401 should come with a WWW-Authenticate header, a 405 with Allow, and a 429 can carry Retry-After.

These headers can be read in the HTTP Header Analyzer. To see the real status line of a request, run it with curl -i; the cURL Command Generator builds the command. When a redirect response sends you to a new address, the URL Parser splits the Location value into its parts.

Often-confused codes

  • 401 and 403. 401 Unauthorized means the request has no valid credentials, so logging in may help. 403 Forbidden means that the server understood who you are and still refuses.
  • 301, 302, 307 and 308. 301 and 308 are permanent redirects, 302 and 307 are temporary. 307 and 308 keep the original method, for example POST, while older clients may change it to GET for 301 and 302.
  • 500, 502, 503 and 504. 500 is an error inside the server. 502 means a gateway received an invalid answer from the server behind it, 503 means the service is temporarily unavailable, and 504 means the gateway waited too long.
  • 429 Too Many Requests. The client is being rate limited. A Retry-After header may say when to try again.
  • 418 I’m a teapot. A joke status from the 1998 April Fools’ RFC 2324, which some APIs use deliberately.

To look at the headers that came with a response, use the HTTP Header Analyzer, and to build a request, use the cURL Command Generator.

Frequently asked questions

What do the code ranges mean?

1xx are informational, 2xx mean success, 3xx are redirects, 4xx are client errors and 5xx are server errors.

Which code should my API return when a record is not found?

404 Not Found. Use 400 for a request that is badly formed and 422 for data that is well formed but fails validation.

How do I find a code quickly?

Type a number or a word in the search box, for example “redirect”, which shows 301, 302, 303, 307 and 308, or use the class filter. The list has 69 codes, each with a plain-English meaning.

Privacy

This tool runs entirely in your browser. What you enter is processed on your device and is not sent to a server.

Share this tool

Your data is not included in this link.