oktools

HTTP Status Codes

Every HTTP status code with what it means, when to send it, the headers that go with it and where it is defined — from 100 Continue to 511 Network Authentication Required, plus the unofficial codes you will meet from nginx, Cloudflare and Laravel. Search by number or by word, and see the codes people mix up — 401 and 403, 400 and 422, 301 and 308, 502 and 504 — compared side by side.

78 codes

1xx Informational

The request was received and is still being processed.

100

100 Continue

The server has received the request headers and the client should go on and send the body.

Sent in answer to a request with Expect: 100-continue, so a client can check that a large upload will be accepted — authorised, not too big — before sending it. Most clients and servers handle it without you seeing it.

RFC 9110 §15.2.1Expect

101

101 Switching Protocols

The server agrees to switch to the protocol the client asked for in its Upgrade header.

What a successful WebSocket handshake returns: the connection stops being HTTP and carries the new protocol from then on. HTTP/2 does not use it.

RFC 9110 §15.2.2UpgradeConnection

102

102 Processing

WebDAV: the server has accepted the request and is still working on it.

Sent to stop a client timing out during a long WebDAV operation. Deprecated, and rarely seen outside WebDAV.

RFC 2518 §10.1

103

103 Early Hints

Headers the final response will carry, sent early so the browser can start preloading.

A server sends Link headers for the stylesheets and fonts a page needs while it is still building the page, and the browser starts fetching them. The real response follows on the same request.

RFC 8297Link

2xx Success

The request was received, understood and accepted.

200

200 OK

The request succeeded, and the body holds the result.

The default success for GET (the resource), POST (the result of the action) and any request with something to return. When there is nothing to return, 204 says so more precisely; when something was created, 201 does.

RFC 9110 §15.3.1cacheable

201

201 Created

The request succeeded and created a new resource.

The answer to a POST (or PUT) that made something. Send a Location header with the new resource's URL, and usually its representation in the body, so the client need not fetch it again.

RFC 9110 §15.3.2Location

202

202 Accepted

The request was accepted for processing, which has not finished — and may yet fail.

For work done asynchronously: a queued job, an export, a payment still clearing. Return a way to follow it, such as a status URL in Location or the body, since 202 itself promises nothing about the outcome.

RFC 9110 §15.3.3LocationRetry-After

203

203 Non-Authoritative Information

Success, but a proxy changed the body from what the origin server sent.

Sent by a transforming proxy rather than by an API. You will rarely need it.

RFC 9110 §15.3.4cacheable

204

204 No Content

The request succeeded and there is nothing to send back.

The usual answer to a DELETE, or a PUT or PATCH that returns nothing. A 204 must not have a body, so clients that try to parse one as JSON fail — check the status before reading.

RFC 9110 §15.3.5cacheable

205

205 Reset Content

Success; the client should reset the document view, such as clearing a form.

Meant for forms that should be emptied after submitting. Browsers do not act on it, so it is rarely used.

RFC 9110 §15.3.6

206

206 Partial Content

The body holds only the byte ranges the client asked for with a Range header.

How resumable downloads and video seeking work. The Content-Range header says which bytes these are; several ranges come back as multipart/byteranges.

RFC 9110 §15.3.7cacheableRangeContent-RangeAccept-Ranges

207

207 Multi-Status

WebDAV: the body holds a separate status for each of several resources.

Some APIs borrow it for batch operations where some items succeed and others fail, with a per-item status in the body.

RFC 4918 §11.1

208

208 Already Reported

WebDAV: members of this binding were already listed earlier in the same 207 response.

Used inside a 207 body to avoid listing the same resource twice. Not used on its own.

RFC 5842 §7.1

226

226 IM Used

The body is the result of delta encoding applied to the current resource.

Part of an HTTP delta-encoding extension that never caught on. You are unlikely to meet it.

RFC 3229 §10.4.1

3xx Redirection

The client must go somewhere else to complete the request.

300

300 Multiple Choices

There are several representations to choose from, and the server is not choosing.

Rarely used: content negotiation usually picks one representation instead.

RFC 9110 §15.4.1cacheable

301

301 Moved Permanently

The resource has a new permanent URL, given in Location.

For pages that moved for good: search engines move their ranking to the new URL and browsers cache the redirect. Clients may turn a POST into a GET when following it, so use 308 when the method must be kept.

RFC 9110 §15.4.2cacheableLocation

302

302 Found

The resource is temporarily at the URL in Location.

The everyday temporary redirect, such as to a login page. Like 301, clients may change a POST into a GET; 307 is the version that keeps the method and body.

RFC 9110 §15.4.3Location

303

303 See Other

Get the result from the URL in Location, with a GET.

The redirect for after a form POST (Post/Redirect/Get): the browser loads the result page with GET, so a refresh does not submit the form again.

RFC 9110 §15.4.4Location

304

304 Not Modified

The client's cached copy is still current, so no body is sent.

The answer to a conditional GET — If-None-Match with an ETag, or If-Modified-Since — when nothing changed. It saves sending the body again.

RFC 9110 §15.4.5ETagIf-None-MatchIf-Modified-Since

305

305 Use Proxy

Deprecated: the resource had to be reached through a proxy.

Deprecated for security reasons; clients ignore it.

RFC 9110 §15.4.6

307

307 Temporary Redirect

Repeat the same request, same method and body, at the URL in Location — this time.

A 302 that is not allowed to change the method, so a POST stays a POST. Browsers also use it internally for HSTS upgrades from http to https.

RFC 9110 §15.4.8Location

308

308 Permanent Redirect

The resource has moved for good; repeat the same request, method and body, at Location.

A 301 that keeps the method. The right redirect for an API endpoint that moved, since clients must not turn a POST into a GET.

RFC 9110 §15.4.9cacheableLocation

4xx Client error

The request has a problem the client must fix before trying again.

400

400 Bad Request

The server cannot process the request because of something the client sent.

Malformed JSON, a missing required field, a parameter of the wrong type. Say what was wrong in the body — an application/problem+json document (RFC 9457) is the standard shape. Some APIs keep 400 for syntax and use 422 for well-formed data that fails validation.

RFC 9110 §15.5.1

401

401 Unauthorized

The request has no valid credentials: the client is not authenticated.

Despite the name, it means unauthenticated: no token, an expired one, or a bad signature. It must carry a WWW-Authenticate header naming the scheme to use. If the client is known but not allowed, that is 403.

RFC 9110 §15.5.2WWW-AuthenticateAuthorization

402

402 Payment Required

Reserved for future use; in practice, a billing problem.

Never standardised, but used by some APIs (Stripe, Shopify, SaaS plans) when an account must pay or upgrade before the request can go through.

RFC 9110 §15.5.3

403

403 Forbidden

The server understood who the client is and refuses the request.

Authenticated but not allowed: the wrong role, a missing scope, an IP that is blocked. Logging in again will not help. Some servers return 404 instead, so as not to reveal that the resource exists.

RFC 9110 §15.5.4

404

404 Not Found

There is nothing at this URL.

The resource does not exist, or the server will not say that it does. A wrong path, a deleted record or a typo in an ID all give 404. If it existed and is gone for good, 410 says that.

RFC 9110 §15.5.5cacheable

405

405 Method Not Allowed

The URL exists, but not for this method.

A DELETE on a read-only resource, or a POST to something that only takes GET. The Allow header must list the methods that are allowed.

RFC 9110 §15.5.6cacheableAllow

406

406 Not Acceptable

The server cannot produce any format the Accept headers allow.

The client sent Accept: application/xml to an API that only speaks JSON, for example. Many servers ignore Accept and send their default instead.

RFC 9110 §15.5.7Accept

407

407 Proxy Authentication Required

Like 401, but it is a proxy between client and server that wants credentials.

Sent by a corporate or authenticating proxy, with a Proxy-Authenticate header.

RFC 9110 §15.5.8Proxy-Authenticate

408

408 Request Timeout

The client took too long to send its request, and the server closed the connection.

About the client being slow to send, not the server being slow to answer — that would be a 504 from a gateway. Clients may retry.

RFC 9110 §15.5.9

409

409 Conflict

The request conflicts with the current state of the resource.

Creating something that already exists, an edit based on an outdated version, a state transition that is not allowed. Explain the conflict in the body so the client can resolve it.

RFC 9110 §15.5.10

410

410 Gone

The resource used to be here and has been removed for good.

A stronger 404: search engines drop the URL sooner, and clients know not to retry. Useful for retired API versions and deleted content.

RFC 9110 §15.5.11cacheable

411

411 Length Required

The server needs a Content-Length header and the request did not have one.

Usually a streamed (chunked) upload to a server that does not accept those.

RFC 9110 §15.5.12Content-Length

412

412 Precondition Failed

A condition in the request's headers, such as If-Match, was not met.

Optimistic locking: the client sends the ETag it last saw in If-Match, and gets 412 if someone else changed the resource since — instead of overwriting their change.

RFC 9110 §15.5.13If-MatchIf-Unmodified-SinceETag

413

413 Content Too Large

The request body is larger than the server will take.

Often an upload limit in a proxy (nginx's client_max_body_size) rather than in the application. Formerly "Payload Too Large".

RFC 9110 §15.5.14Retry-After

414

414 URI Too Long

The URL is longer than the server will read.

Usually a GET with too much in its query string. Move the data into a POST body, or the QUERY method where supported.

RFC 9110 §15.5.15cacheable

415

415 Unsupported Media Type

The server does not accept the body's format, as given by Content-Type.

The classic: JSON sent without Content-Type: application/json, or a form sent where JSON was expected. Check the header before the body.

RFC 9110 §15.5.16Content-TypeAccept-PostAccept-Patch

416

416 Range Not Satisfiable

The byte range asked for is outside the resource.

A Range header past the end of the file, for example when resuming a download of a file that has since shrunk.

RFC 9110 §15.5.17Content-Range

417

417 Expectation Failed

The server cannot meet the Expect header.

In practice, a server that does not support Expect: 100-continue. Send the request again without it.

RFC 9110 §15.5.18Expect

418

418 I'm a teapot

An April Fools' joke: the server is a teapot and refuses to brew coffee.

From the Hyper Text Coffee Pot Control Protocol (RFC 2324). Reserved so nobody gives the number a real meaning; some sites use it to turn away bots.

RFC 9110 §15.5.19

421

421 Misdirected Request

The request reached a server that cannot answer for this host.

Seen with HTTP/2 connection reuse when a certificate covers several hosts but the server does not serve them all. The client should retry on a new connection.

RFC 9110 §15.5.20

422

422 Unprocessable Content

The body is well-formed but its content fails validation.

Valid JSON with an invalid email, a date in the past, a quantity of zero. Many APIs use it to tell validation errors apart from malformed requests (400). Formerly "Unprocessable Entity".

RFC 9110 §15.5.21

423

423 Locked

WebDAV: the resource is locked.

Some APIs use it for records being edited by someone else.

RFC 4918 §11.3

424

424 Failed Dependency

WebDAV: the request failed because an earlier one it depended on failed.

Used in batch and multi-step operations.

RFC 4918 §11.4

425

425 Too Early

The server will not process a request that might be replayed.

Sent for requests in TLS 1.3 early data (0-RTT), which an attacker could replay. The client should retry after the handshake completes.

RFC 8470 §5.2

426

426 Upgrade Required

The server will only answer over a different protocol, named in Upgrade.

For example an endpoint that requires a newer TLS or HTTP version.

RFC 9110 §15.5.22Upgrade

428

428 Precondition Required

The server requires a conditional request, such as one with If-Match.

Forces clients to use optimistic locking, so two edits cannot silently overwrite each other (the "lost update" problem).

RFC 6585 §3If-Match

429

429 Too Many Requests

The client has sent too many requests in a given time: it is rate limited.

Send a Retry-After header saying when to try again, and back off exponentially when there is none. RateLimit headers are often sent with it to show the quota.

RFC 6585 §4Retry-AfterRateLimitRateLimit-Policy

431

431 Request Header Fields Too Large

The headers, one or all of them together, are too large.

Most often too many or too big cookies, or an oversized token. Clearing cookies for the site usually fixes it in a browser.

RFC 6585 §5

451

451 Unavailable For Legal Reasons

The resource cannot be served for legal reasons, such as a court order or censorship.

The number is a nod to Fahrenheit 451. A Link header with rel="blocked-by" can say who requires the block.

RFC 7725 §3Link

5xx Server error

The server failed to fulfil a request that looked valid.

500

500 Internal Server Error

Something went wrong on the server and it has no more specific code for it.

An unhandled exception, a bug, a misconfiguration. The fault is not the client's, so retrying the same request rarely helps; the server's logs have the cause.

RFC 9110 §15.6.1

501

501 Not Implemented

The server does not support the functionality the request needs.

Usually a method the server does not recognise at all. For a method it knows but that this resource does not allow, use 405.

RFC 9110 §15.6.2cacheable

502

502 Bad Gateway

A gateway or proxy got an invalid response from the server behind it.

The load balancer or reverse proxy is up, but the application behind it crashed, refused the connection or sent garbage. Check that the upstream service is running.

RFC 9110 §15.6.3

503

503 Service Unavailable

The server cannot handle the request right now: overloaded or down for maintenance.

A temporary state; send Retry-After so clients know when to come back. Search engines treat a short 503 as maintenance and keep the page indexed.

RFC 9110 §15.6.4Retry-After

504

504 Gateway Timeout

A gateway or proxy did not get a response from the server behind it in time.

The upstream is up but too slow: a slow query, a stuck worker, a timeout in the proxy set too low. Compare with 502, where the upstream answered badly or not at all.

RFC 9110 §15.6.5

505

505 HTTP Version Not Supported

The server does not support the HTTP version of the request.

Rare; most servers speak HTTP/1.1 and negotiate anything newer.

RFC 9110 §15.6.6

506

506 Variant Also Negotiates

A content negotiation misconfiguration on the server.

From an experimental negotiation extension; you are unlikely to see it.

RFC 2295 §8.1

507

507 Insufficient Storage

WebDAV: the server has no room to store what the request needs.

Some storage APIs use it for a full disk or an exhausted quota.

RFC 4918 §11.5

508

508 Loop Detected

WebDAV: the server found an infinite loop while processing the request.

Some hosting platforms also show it when a site exceeds its resource limits.

RFC 5842 §7.2

510

510 Not Extended

The request needs an HTTP extension the client did not declare.

From an extension framework that is now historic.

RFC 2774 §7

511

511 Network Authentication Required

The network wants the client to sign in before it gets access.

Sent by captive portals on hotel and airport Wi-Fi, so a client knows the answer came from the portal and not from the site it asked for.

RFC 6585 §6

Unofficial codes

Not in the IANA registry, but sent or logged by widely used servers and services.

419

419 Page Expired

Laravel: the CSRF token was missing or had expired.

A form was submitted after the session expired, or without the @csrf token. Reloading the page gets a fresh token.

Unofficial · Laravel

420

420 Enhance Your Calm

The old Twitter API's rate-limit response, now 429.

Some older services still send it. Treat it as 429.

Unofficial · Twitter API v1

444

444 No Response

nginx: the server closed the connection without sending anything.

Configured with "return 444" to drop unwanted traffic. It never reaches the client; it only appears in nginx's logs, while the client sees a closed connection.

Unofficial · nginx

494

494 Request Header Too Large

nginx: the request headers are larger than large_client_header_buffers allows.

nginx's own version of 431, usually caused by large cookies.

Unofficial · nginx

495

495 SSL Certificate Error

nginx: the client certificate failed verification.

With mutual TLS, the client presented a certificate that did not verify.

Unofficial · nginx

496

496 SSL Certificate Required

nginx: the server requires a client certificate and none was presented.

With mutual TLS set to required, the client sent no certificate.

Unofficial · nginx

497

497 HTTP Request Sent to HTTPS Port

nginx: a plain HTTP request arrived on the port that expects HTTPS.

Usually a URL written with http:// and an explicit HTTPS port, such as http://example.com:443.

Unofficial · nginx

499

499 Client Closed Request

nginx: the client closed the connection before the server answered.

Shows up in nginx logs when a user navigates away, a client times out, or a load balancer gives up first. Many 499s on one endpoint usually mean it is too slow.

Unofficial · nginx

520

520 Web Server Returned an Unknown Error

Cloudflare: the origin server sent an empty, unknown or unexpected response.

Often the origin crashed, reset the connection, or sent headers too large for Cloudflare.

Unofficial · Cloudflare

521

521 Web Server Is Down

Cloudflare: the origin server refused the connection.

The web server is not running, or a firewall blocks Cloudflare's IP ranges.

Unofficial · Cloudflare

522

522 Connection Timed Out

Cloudflare: the TCP connection to the origin timed out.

The origin is unreachable or overloaded, or a firewall is silently dropping Cloudflare's packets.

Unofficial · Cloudflare

523

523 Origin Is Unreachable

Cloudflare: Cloudflare could not reach the origin server at all.

Usually a wrong IP address in the DNS settings, or a routing problem.

Unofficial · Cloudflare

524

524 A Timeout Occurred

Cloudflare: the origin accepted the connection but took more than 100 seconds to answer.

Move long work to a background job and return 202, or raise the limit on an Enterprise plan.

Unofficial · Cloudflare

525

525 SSL Handshake Failed

Cloudflare: the TLS handshake with the origin failed.

The origin's TLS setup is broken or incompatible — no certificate on the port, or no shared cipher.

Unofficial · Cloudflare

526

526 Invalid SSL Certificate

Cloudflare: the origin's certificate is invalid, with SSL mode set to Full (strict).

The certificate expired, is self-signed, or does not cover the hostname.

Unofficial · Cloudflare

Status codes that are often confused

CodesThe difference
401 vs 403 401: we don't know who you are — authenticate. 403: we know who you are, and the answer is no.
400 vs 422 400: the request can't be read (malformed JSON, wrong type). 422: it reads fine, but the values fail validation.
404 vs 410 404: nothing here, maybe never was, maybe will be. 410: it was here and is gone for good.
301 vs 308 Both permanent. A 301 lets clients turn a POST into a GET; a 308 keeps the method and body.
302 vs 307 vs 303 Temporary. 307 keeps the method, 302 may not, and 303 deliberately switches to GET after a form POST.
200 vs 201 vs 204 200: success with a body. 201: something was created (send Location). 204: success with no body at all.
409 vs 412 409: the request clashes with the resource's state. 412: an If-Match or other precondition the client sent failed.
429 vs 503 429: you, specifically, are sending too much. 503: the service can't take anyone's requests right now.
502 vs 504 From a proxy: 502 means the upstream answered badly or not at all; 504 means it answered too slowly.

How it works

The page is one list of 78 status codes — 63 official ones and 15 unofficial — and every entry carries the same parts: the code and its name, a one-sentence meaning, a paragraph on when to send it and what usually causes it, the RFC section or the vendor it comes from, the headers that belong with it, whether a cache may store it by default, and the codes it is often confused with. All of it is in the HTML as served, so a search can land on /api/http-status-codes#404 directly, and the search box and the class buttons hide entries with CSS rather than removing them.

Searching reads the query as words. A word made of digits matches every code that starts with it, so 30 shows the nine redirects and 42 the 420s; any other word has to appear somewhere in the entry — its name, summary, detail, source or headers — and several words all have to match, which is how rate limit finds 429 and 420 and retry-after finds every code whose entry names that header. Pressing Enter on an exact code jumps to it, as does following a #code link, which clears a filter that was hiding the entry and highlights it for a moment.

The entries are written as answers rather than definitions: 401 says it means unauthenticated despite its name, 404 says when 410 is the better choice, 503 says to send Retry-After. The See also links join the pairs people search for — 401 and 403, 400 and 422, 502 and 504 — and the table beneath the list puts each pair’s difference in one line. The unofficial section covers what appears in logs without being in any RFC: nginx’s 499 and 444, Cloudflare’s 520 to 526, Laravel’s 419 and Twitter’s 420, each marked with who sends it.

Examples

Decide between 400 and 422

Each code links to the other under See also, and the two entries give the convention: 400 when the request cannot be read, 422 when it reads fine and the values are wrong. Typing either number shows all the codes that start with it, so 42 lists 420 to 429.

Codes
400
422
Entries
400 Bad Request
The server cannot process the request because of something the client sent.
Malformed JSON, a missing required field, a parameter of the wrong type. Say what was wrong in the body — an application/problem+json document (RFC 9457) is the standard shape. Some APIs keep 400 for syntax and use 422 for well-formed data that fails validation.

422 Unprocessable Content
The body is well-formed but its content fails validation.
Valid JSON with an invalid email, a date in the past, a quantity of zero. Many APIs use it to tell validation errors apart from malformed requests (400). Formerly "Unprocessable Entity".

Look up a code from an nginx log

499 is not in any RFC, so most references do not list it. Here it sits in the Unofficial section with who sends it, and its See also points at 408 and 504, the official codes for the two sides of the same timeout.

Search
499
Entry
499 Client Closed Request
nginx: the client closed the connection before the server answered.
Shows up in nginx logs when a user navigates away, a client times out, or a load balancer gives up first. Many 499s on one endpoint usually mean it is too slow.
Unofficial · nginx

Search by what happened

Both words have to appear in an entry, so the match is 429 and Twitter’s old 420, with the count shown beside the filter buttons. The chips under an entry are the headers that go with it, which is where Retry-After and the RateLimit headers are found.

Search
rate limit
Result
2 codes: 420 Enhance Your Calm, 429 Too Many Requests

429 Too Many Requests
The client has sent too many requests in a given time: it is rate limited.
Send a Retry-After header saying when to try again, and back off exponentially when there is none. RateLimit headers are often sent with it to show the quota.
Retry-After · RateLimit · RateLimit-Policy

Tell 502 from 504

The word gateway appears in three entries, 408 among them because its detail says a server being slow would be a 504 from a gateway. The two 5xx entries draw the line: a bad or missing answer from the upstream against no answer in time.

Search
gateway
Result
3 codes: 408 Request Timeout, 502 Bad Gateway, 504 Gateway Timeout

502 Bad Gateway
A gateway or proxy got an invalid response from the server behind it.
The load balancer or reverse proxy is up, but the application behind it crashed, refused the connection or sent garbage. Check that the upstream service is running.

504 Gateway Timeout
A gateway or proxy did not get a response from the server behind it in time.
The upstream is up but too slow: a slow query, a stuck worker, a timeout in the proxy set too low. Compare with 502, where the upstream answered badly or not at all.

Supported formats

  • Official codes with their sourceEvery registered code from 100 to 511 with the section of RFC 9110 or the RFC that defines it — 6585 for 428, 429 and 431, 7725 for 451, 8297 for 103 — linked to the text, so the definition is one click from the summary.
  • Unofficial codesnginx’s 444, 494 to 497 and 499, Cloudflare’s 520 to 526, Laravel’s 419 and Twitter’s 420, each marked unofficial with who sends it, in a section of their own at the end of the list.
  • Headers and cachingEach entry lists the headers that belong with it — WWW-Authenticate on 401, Location on 201 and the redirects, Retry-After on 429 and 503 — and the twelve codes RFC 9110 lets a cache store without being told to are marked cacheable.
  • A link for every codeEach entry has its own URL, such as /api/http-status-codes#404, that a code review, a runbook or an error page can point at.

Use cases

  • Pick the right code for an API errorCompare 400 with 422, 401 with 403 and 409 with 412 before writing the handler, so clients can tell a request they must fix from one they must authenticate or retry.
  • Explain a code from a logSearch the number from an nginx, load-balancer or CDN log — 499, 502, 524 — and read who sends it and what it usually says about the service behind the proxy.
  • Choose a redirectThe 301, 302, 303, 307 and 308 entries say which keep the method and body, which search engines treat as permanent and which browsers cache.
  • Point a colleague at a meaningEvery entry has an anchor, so a review comment can link the exact text for 428 or 451 rather than paraphrasing it.

Limitations

  • A reference, not a checkerIt does not send requests or inspect a response. To see what an endpoint actually returns, send the request from the Online API Client or open a capture in the HAR Viewer.
  • Guidance, not lawWhen to use 400 against 422, or 200 against 204, is convention. The entries give the common one, and your own API style guide may differ.
  • Not every vendor codeOnly widely seen unofficial codes are listed. A code specific to one product or proxy, such as 430 or 561, will not be found here; the vendor’s documentation is the place for it.
  • Search is by text, in EnglishA word matches only where it appears in an entry, so a synonym or a translated term finds nothing; search by number when the word does not match.

Frequently asked questions

What is the difference between 401 and 403?

401 Unauthorized means the server does not know who you are: there were no credentials, or they were invalid or expired, so logging in or refreshing the token can fix it. It must come with a WWW-Authenticate header saying how to authenticate. 403 Forbidden means the server knows exactly who you are and refuses anyway — the wrong role, a missing scope, a blocked IP — so sending the same credentials again will not help. The names are historical: 401 is really "unauthenticated" and 403 is "unauthorised".

Should an API return 400 or 422 for validation errors?

Both are used. A common convention is 400 Bad Request when the request cannot be read at all — malformed JSON, a wrong Content-Type, a missing required parameter — and 422 Unprocessable Content when the body is well-formed but its values fail validation, such as an invalid email or an end date before the start date. Rails, Laravel and many JSON:API services follow it; others return 400 for everything. Whichever you pick, say what was wrong in the body, ideally as application/problem+json (RFC 9457) with an entry per invalid field.

What is the difference between 301, 302, 307 and 308 redirects?

301 and 308 are permanent: search engines move the old URL's ranking to the new one and browsers cache the redirect. 302 and 307 are temporary. The other difference is the method: on a 301 or 302 a client may turn a POST into a GET, while a 307 or 308 must repeat the same method with the same body. So redirect pages with 301 (permanent) or 302 (temporary), and API endpoints with 308 or 307, where a POST must stay a POST. 303 See Other is the deliberate POST-to-GET redirect used after submitting a form.

What is the difference between 502, 503 and 504?

All three usually come from a load balancer or reverse proxy in front of the application, not from the application itself. 502 Bad Gateway means the proxy reached the application and got nothing valid back — it crashed, refused the connection, or sent a broken response. 504 Gateway Timeout means the application is reachable but did not answer before the proxy gave up, often a slow query or a stuck worker. 503 Service Unavailable means the service is deliberately or temporarily unable to take requests, such as during maintenance or overload, ideally with a Retry-After header.

Should a successful DELETE return 200 or 204?

Either is correct. Return 204 No Content when there is nothing useful to send back, which is the most common choice, and 200 OK when the body carries something, such as the deleted resource or a summary of what was removed. If the deletion is queued rather than done, return 202 Accepted. For creating, return 201 Created with a Location header pointing at the new resource. A 204 must not have a body, so clients should check the status before parsing JSON.

What does status code 499 mean?

499 Client Closed Request is not a standard code: nginx writes it in its access log when the client closed the connection before the server sent a response. The client never receives it. It appears when a user navigates away or cancels, when a client or an upstream load balancer has a shorter timeout than the server, or when a request simply took too long. A steady stream of 499s on one endpoint usually means that endpoint is too slow for the timeouts in front of it.

Which status codes can a cache store without being told to?

RFC 9110 makes 200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414 and 501 cacheable by default: a cache may store them and work out a freshness lifetime itself when the response has no Cache-Control or Expires header. That is why a permanent 301 can stick in a browser long after the redirect is removed, and why a 404 for a URL that later exists can linger in a CDN. Any other status is only cached when its headers explicitly allow it. These codes are marked "cacheable" in the list above.