Skip to content

By the Octri team · Updated

HTTP status codes

Share

Every HTTP status code, from 100 Continue to 511 Network Authentication Required, with what each one means. A status code is the three-digit number at the start of every HTTP response, and its first digit says which class it belongs to.

The 18 codes linked in orange have a page of their own, for the people who choose what their API returns. Each one says when to return the code, how eleven well-known public OpenAPI specs declare it, how to describe it in yours, and what an Octri SDK does when it gets one.

1xx informational

Interim answers sent before the final response. Most API clients never see them.

CodeNameWhat it means
100ContinueThe headers were fine, so the client can send the body it held back after Expect: 100-continue.
101Switching ProtocolsThe server agrees to change protocol, as when an HTTP connection becomes a WebSocket.
102ProcessingA WebDAV server is still working on the request. Deprecated and rarely sent.
103Early HintsHeaders like Link: rel=preload sent ahead of the final response, so a browser can start loading assets.

2xx success

The request worked. The code says what kind of success it was.

CodeNameWhat it means
200OKThe request worked, and the body holds the result.
201CreatedThe request created a resource, usually named in the Location header.
202AcceptedThe request was queued and the work will finish later, with no promise about the outcome.
203Non-Authoritative InformationA proxy changed the origin server’s successful response before passing it on.
204No ContentThe request worked and there is no body to send back.
205Reset ContentThe request worked, and the client should reset the form or view that sent it.
206Partial ContentThe body holds only the byte range the client asked for with a Range header.
207Multi-StatusA WebDAV response with a separate status for each of several resources.
208Already ReportedA WebDAV binding member already listed earlier in the same response.
226IM UsedThe body is the result of delta encoding applied to the current resource.

3xx redirection

The client has to go somewhere else, or use the copy it already has.

CodeNameWhat it means
300Multiple ChoicesThe resource has several representations, and the client should pick one.
301Moved PermanentlyThe resource has a new URL for good. Clients may turn a POST into a GET when they follow it.
302FoundThe resource is at another URL for now. Clients may turn a POST into a GET when they follow it.
303See OtherThe result is at another URL, to be fetched with GET, often after a POST.
304Not ModifiedThe client’s cached copy is still current, so the server sends no body.
305Use ProxyDeprecated for security reasons. Clients ignore it.
306(Unused)Used in an early draft and reserved since. No server should send it.
307Temporary RedirectThe resource is at another URL for now, and the client must repeat the same method and body there.
308Permanent RedirectThe resource has a new URL for good, and the client must repeat the same method and body there.

4xx client errors

Something about the request is wrong, and sending it again unchanged will usually fail again.

CodeNameWhat it means
400Bad RequestThe request is malformed, like JSON that doesn’t parse or a missing required field.
401UnauthorizedThe request has no valid credentials, so the server doesn’t know who is calling.
402Payment RequiredReserved for future use. Some APIs send it when an account needs to pay.
403ForbiddenThe server knows the caller and won’t let them do this.
404Not FoundNothing exists at this URL, or the server won’t say that it does.
405Method Not AllowedThe URL exists and doesn’t accept this method. The Allow header lists the ones it does.
406Not AcceptableThe server can’t produce a response in any format the Accept header asks for.
407Proxy Authentication RequiredLike a 401, for a proxy between the client and the server.
408Request TimeoutThe client took too long to send the request, so the server closed the connection.
409ConflictThe request clashes with the resource’s current state, like a duplicate email.
410GoneThe resource was removed for good and won’t come back.
411Length RequiredThe server needs a Content-Length header and the request didn’t send one.
412Precondition FailedA condition the client sent, like If-Match, was false.
413Content Too LargeThe request body is bigger than the server will take. Formerly Payload Too Large.
414URI Too LongThe URL is longer than the server will process, often from a huge query string.
415Unsupported Media TypeThe server won’t accept the body in the format named by Content-Type.
416Range Not SatisfiableThe byte range in the Range header is outside the resource.
417Expectation FailedThe server can’t meet the Expect header the client sent.
418(Unused)Reserved after the 1998 April Fools’ RFC that named it “I’m a teapot”. Some servers send it as a joke.
421Misdirected RequestThe request reached a server that can’t answer for that host, often over a reused HTTP/2 connection.
422Unprocessable ContentThe request parsed and the data breaks a rule. Formerly Unprocessable Entity.
423LockedA WebDAV resource is locked by someone else.
424Failed DependencyA WebDAV request failed because another action it depended on failed.
425Too EarlyThe server won’t risk processing a request sent in TLS early data, which could be replayed.
426Upgrade RequiredThe server won’t answer over this protocol. The Upgrade header names the one it wants.
428Precondition RequiredThe server needs a conditional request, usually with If-Match, and this one had none.
429Too Many RequestsThe client went over a rate limit. Retry-After says how long to wait.
431Request Header Fields Too LargeOne header, or all of them together, is too big, often an oversized cookie.
451Unavailable For Legal ReasonsThe server can’t serve the resource because of a legal demand, like a court order.

5xx server errors

The server failed on a request that may have been fine. Some of these are safe to retry.

CodeNameWhat it means
500Internal Server ErrorSomething unexpected failed on the server.
501Not ImplementedThe server doesn’t support what the request needs, on any resource.
502Bad GatewayA proxy or gateway got an invalid response from the server behind it.
503Service UnavailableThe server is overloaded or down for maintenance and expects to recover.
504Gateway TimeoutA proxy or gateway gave up waiting for the server behind it.
505HTTP Version Not SupportedThe server won’t use the HTTP version the request came in.
506Variant Also NegotiatesThe server’s content negotiation is misconfigured and loops on itself.
507Insufficient StorageA WebDAV server has no room to store what the request needs.
508Loop DetectedA WebDAV server found an infinite loop while processing the request.
510Not ExtendedThe request needs an HTTP extension the server doesn’t have. Obsolete.
511Network Authentication RequiredA captive portal, like hotel Wi-Fi, wants the client to sign in first.

Unofficial codes you will meet

No RFC defines these. Specific servers and CDNs send them, so they show up in logs.

CodeNameWhat it means
499Client Closed Requestnginx logs this when the client hung up before the server answered.
520Web Server Returned an Unknown ErrorCloudflare got an empty or unexpected response from the origin server.
521Web Server Is DownCloudflare couldn’t connect to the origin server at all.
522Connection Timed OutCloudflare’s connection to the origin server timed out.
523Origin Is UnreachableCloudflare couldn’t find a route to the origin server.
524A Timeout OccurredCloudflare connected to the origin server and it didn’t answer in time.

HTTP status code questions

Does an API need every status code?

No. Most APIs get by with about a dozen: 200, 201, 202 and 204 for success, 400, 401, 403, 404, 409, 422 and 429 for client errors, and 500 and 503 for server errors. Add others where they say something those don’t.

Should an API return 200 with an error in the body?

No. Clients, proxies and monitoring read the status code first, so an error behind a 200 looks like a success to all of them. Slack does this, and a generated SDK has to be told which field holds the error.

Can an API invent its own status codes?

Partly. HTTP allows any three-digit code, and clients treat an unknown one like the x00 of its class. Nothing outside your own clients will know what it means, so a standard code with a precise error body is easier to work with.

Share