Status codes · 1xx–5xx
4xx: 400–451 request, representation and resource errors
Learn the differences between 400/404/405/406/415/422 and correct client reactions.
Understand the concept
400 is a general request error such as malformed syntax. 404 means the target is unavailable or its existence is not disclosed; 410 communicates a known permanent loss of availability. 405 identifies a method not allowed for this resource and requires Allow. It differs from a server that cannot implement required functionality.
406 concerns an acceptable response representation; 415 concerns unsupported request content. Accept expresses response preferences while Content-Type identifies the supplied body. 413, 414 and 431 concern body, URI and header size respectively. 422 describes instructions that cannot be processed despite understood content syntax. Choose a consistent validation contract rather than changing codes unpredictably.
408 describes the server not receiving a request in time, not every client timeout. 416 concerns ranges; 421 concerns routing; 425 concerns unsafe early-data processing; 426 concerns upgrading protocols; 451 concerns legal restrictions. Decide which input can be corrected and whether retrying is safe.
When producing validation responses and appropriate frontend error states.
Confusing 406 with 415 or automatically retrying all 4xx responses.
One topic. Three levels of depth.
Content-Type: image/png
HTTP/1.1 415 Unsupported Media TypeA JSON-only endpoint rejects this body type.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
XML was sent to a JSON-only endpoint. Is it 406 or 415?
Show the solution and explanation
HTTP/1.1 415 Unsupported Media TypeThe issue is the supplied representation type; 406 concerns response preferences.