bitlvl
IT

Codici di stato HTTP

Cerca per numero o parola. L’ultima colonna è la situazione che di solito produce il codice, che è ciò che ti serve quando ne stai fissando uno in un log. La tabella è in inglese.

 
 
CodiceNomeSignificatoQuando lo vedi
100Continue
Informativo
The server has received the headers; send the body.After Expect: 100-continue, before uploading a large body.
101Switching Protocols
Informativo
The server agrees to change protocol.WebSocket handshake.
102Processing
Informativo
WebDAV: request accepted, still working.
103Early Hints
Informativo
Preliminary headers, mainly Link: rel=preload, before the final response.CDNs and Cloudflare to start loading assets early.
200OK
Successo
The request succeeded.The normal case.
201Created
Successo
A new resource was created; Location header points to it.POST to a collection in a REST API.
202Accepted
Successo
Accepted for processing, not finished.Async jobs and queues.
203Non-Authoritative Information
Successo
Response modified by a proxy.Rare.
204No Content
Successo
Success with nothing to return.DELETE, PUT, beacon endpoints, preflight responses.
205Reset Content
Successo
Success; the client should reset the form.Rare.
206Partial Content
Successo
Only the requested byte range is returned.Video streaming, resumable downloads (Range header).
207Multi-Status
Successo
WebDAV: multiple status codes in an XML body.
226IM Used
Successo
Delta encoding applied.Rare.
300Multiple Choices
Reindirizzamento
Several representations are available.Rare.
301Moved Permanently
Reindirizzamento
The resource has a new permanent URL; the browser caches the redirect. Method may change to GET.http→https, old URLs, www canonicalisation. Transfers SEO ranking.
302Found
Reindirizzamento
Temporary redirect; method may change to GET.Post-login redirects, A/B tests. Not cached by default.
303See Other
Reindirizzamento
Redirect to a different resource with GET.After a POST (post/redirect/get pattern).
304Not Modified
Reindirizzamento
The cached copy is still valid; no body.Conditional requests with If-None-Match / If-Modified-Since.
307Temporary Redirect
Reindirizzamento
Like 302 but the method and body must not change.Redirecting a POST without turning it into a GET; HSTS internal redirects in Chrome.
308Permanent Redirect
Reindirizzamento
Like 301 but the method and body must not change.Permanent redirects of API endpoints.
400Bad Request
Errore del client
The request is malformed; the server will not process it.Invalid JSON, bad parameters, oversized headers, invalid Host.
401Unauthorized
Errore del client
Authentication is required or failed. The response should say how (WWW-Authenticate).Missing or expired token. (Should have been called Unauthenticated.)
402Payment Required
Errore del client
Reserved; used by some APIs for quota or billing problems.Stripe, some SaaS APIs, Cloudflare for some plan limits.
403Forbidden
Errore del client
Authenticated (or not) but not allowed.Permission denied, WAF block, directory listing disabled, Cloudflare challenges.
404Not Found
Errore del client
No resource at this URL.Typos, deleted pages, wrong routes. Should return a helpful page.
405Method Not Allowed
Errore del client
The URL exists but not for this method; Allow header lists the valid ones.POST to a static file, GET on a webhook endpoint.
406Not Acceptable
Errore del client
No representation matches the Accept headers.Rare; strict content negotiation.
407Proxy Authentication Required
Errore del client
Authenticate with the proxy first.Corporate proxies.
408Request Timeout
Errore del client
The server gave up waiting for the request.Slow clients; browsers retry silently.
409Conflict
Errore del client
The request conflicts with the current state.Duplicate create, version mismatch, edit collisions.
410Gone
Errore del client
Permanently removed, and the server knows it.Tells search engines to drop the URL faster than 404.
411Length Required
Errore del client
Content-Length header missing.Some servers for chunked uploads.
412Precondition Failed
Errore del client
An If-* condition failed.Optimistic concurrency with ETags (If-Match).
413Content Too Large
Errore del client
Body exceeds the limit.nginx client_max_body_size, upload limits.
414URI Too Long
Errore del client
The URL exceeds the limit (typically 8 KB).Huge GET query strings; use POST.
415Unsupported Media Type
Errore del client
The Content-Type is not supported.Sending form data where JSON is expected.
416Range Not Satisfiable
Errore del client
The Range header is outside the file.Broken resumable downloads.
417Expectation Failed
Errore del client
The Expect header cannot be met.Old proxies with Expect: 100-continue.
418I'm a teapot
Errore del client
April Fools RFC 2324.Easter eggs; some sites use it to reject bots.
421Misdirected Request
Errore del client
Sent to a server that cannot produce a response for this host.HTTP/2 connection reuse across hostnames with the wrong certificate.
422Unprocessable Content
Errore del client
Syntactically valid but semantically wrong.Validation errors in REST APIs (Rails, Laravel, GitHub).
423Locked
Errore del client
WebDAV: resource is locked.
424Failed Dependency
Errore del client
WebDAV: a previous request failed.
425Too Early
Errore del client
The server will not process a request that might be replayed (TLS 1.3 0-RTT).
426Upgrade Required
Errore del client
Switch to a different protocol.Forcing TLS or HTTP/2.
428Precondition Required
Errore del client
The request must be conditional.APIs enforcing If-Match to prevent lost updates.
429Too Many Requests
Errore del client
Rate limit hit; Retry-After says when to try again.API throttling, login brute-force protection, Cloudflare rate limiting.
431Request Header Fields Too Large
Errore del client
Headers exceed the limit.Huge cookies.
451Unavailable For Legal Reasons
Errore del client
Blocked by a legal demand.Geo-blocking for GDPR, court orders.
500Internal Server Error
Errore del server
The server hit an unexpected error.Uncaught exceptions, misconfiguration. Check the server logs, not the browser.
501Not Implemented
Errore del server
The server does not support the method.Rare; PATCH on old servers.
502Bad Gateway
Errore del server
A proxy got an invalid response from the upstream.App server crashed or not listening; nginx/HAProxy/Cloudflare in front of a dead backend.
503Service Unavailable
Errore del server
Temporarily unable to handle the request.Maintenance, overload, all backends down. Send Retry-After.
504Gateway Timeout
Errore del server
The upstream did not answer in time.Slow backend behind a proxy (proxy_read_timeout, Cloudflare’s 100 s limit).
505HTTP Version Not Supported
Errore del server
The HTTP version is not supported.Rare.
507Insufficient Storage
Errore del server
WebDAV: out of space.
508Loop Detected
Errore del server
WebDAV: infinite loop.
510Not Extended
Errore del server
Further extensions required.Rare.
511Network Authentication Required
Errore del server
Log in to the network first.Captive portals in hotels and airports.
520Cloudflare: Unknown Error
Cloudflare
The origin returned something Cloudflare could not interpret (empty reply, invalid headers, > 16 KB headers).Origin resets the connection or sends garbage.
521Cloudflare: Web Server Is Down
Cloudflare
Cloudflare could not connect to the origin on the port.Origin firewall blocking Cloudflare IPs, web server stopped.
522Cloudflare: Connection Timed Out
Cloudflare
TCP handshake with the origin timed out.Origin overloaded or unreachable, wrong DNS IP.
523Cloudflare: Origin Is Unreachable
Cloudflare
No route to the origin.Wrong IP in DNS, origin network down.
524Cloudflare: A Timeout Occurred
Cloudflare
TCP connected but the origin did not send a response within 100 seconds.Slow scripts, long reports, big uploads; move the work async.
525Cloudflare: SSL Handshake Failed
Cloudflare
TLS handshake with the origin failed.Full (strict) mode without a valid origin certificate, cipher mismatch.
526Cloudflare: Invalid SSL Certificate
Cloudflare
Origin certificate not trusted (Full strict).Self-signed origin cert; use a Cloudflare Origin Certificate.
530Cloudflare: Origin DNS Error / 1xxx
Cloudflare
Returned with a 1xxx error code in the body.Tunnel down, DNS error, bans.

I risultati e i messaggi di questo strumento sono mostrati in inglese.

Le cinque classi

1xx informativi, raramente visti al di fuori degli upgrade di protocollo. 2xx successo. 3xx reindirizzamento: il client deve guardare altrove. 4xx il client ha fatto qualcosa di sbagliato (o non è autorizzato). 5xx il server ha fallito. Un browser o un client che incontra un codice sconosciuto lo tratta come l’x00 della sua classe, così i nuovi codici degradano con grazia.

Coppie che si confondono

  • 301 contro 302 contro 307/308: 301 e 308 sono permanenti (in cache, e i motori di ricerca spostano il ranking); 302 e 307 sono temporanei. Le varianti 7/8 vietano di cambiare il metodo, quindi un POST resta un POST; 301/302 lasciano che il browser lo trasformi in un GET. Usa 308 per spostamenti permanenti di API, 301 per pagine web, 303 dopo il POST di un form.
  • 401 contro 403: 401 significa «chi sei?» (credenziali mancanti o sbagliate; riprova con autenticazione). 403 significa «so chi sei e la risposta è no». Restituire 404 invece di 403 è legittimo quando non vuoi rivelare che la risorsa esiste.
  • 502 contro 503 contro 504: vengono tutti da un proxy davanti alla tua app. 502: il backend ha risposto con spazzatura o ha chiuso la connessione (crash, porta sbagliata). 503: niente di disponibile (manutenzione, tutti i backend giù, sovraccarico). 504: il backend ha impiegato troppo. I codici 52x di Cloudflare li raffinano ulteriormente.
  • 400 contro 422: 400 per una richiesta che il server non riesce affatto ad analizzare; 422 per una che ha analizzato ma rifiuta in validazione. Molte API usano 400 per entrambi.

Cloudflare 52x

Cloudflare aggiunge i propri codici per i problemi tra il suo edge e la tua origine. 521 significa che non ha potuto aprire una connessione TCP (firewall, server giù), 522 che la connessione è andata in timeout (IP sbagliato, sovraccarico), 524 che la connessione ha funzionato ma l’origine non ha risposto entro 100 secondi, 525/526 problemi TLS con il certificato dell’origine (passa a Full strict con un Origin Certificate, o a Flexible). Puntano sempre al tuo server o al percorso verso di esso, mai al visitatore.

Domande

Che differenza c’è tra 404 e 410?

404 dice che ora qui non c’è nulla; 410 dice che c’era ed è stato rimosso di proposito. I motori di ricerca abbandonano più in fretta un URL 410. Usa 410 per contenuti eliminati che non ripristinerai.

Un’API dovrebbe restituire 200 con un errore nel corpo?

No. Client, proxy, cache e monitoraggio si basano tutti sul codice di stato. Usa 4xx per gli errori del client e 5xx per i fallimenti del server, con i dettagli nel corpo (RFC 9457 problem+json è la forma standard).

Perché ricevo 502 da nginx?

nginx non è riuscito a ottenere una risposta valida dall’upstream: l’app non è in esecuzione, ascolta su un’altra porta o socket, è andata in crash a metà richiesta, o ha inviato header che nginx ha rifiutato. Controlla i log dell’app e l’error log di nginx, non il browser.

Cosa significa 429 e cosa devo fare?

Troppe richieste: hai raggiunto un limite di frequenza. Aspetta il tempo indicato nell’header Retry-After, poi riprova con backoff. Per le API, distribuisci le chiamate o richiedi una quota maggiore.