Códigos de estado HTTP

Todos los códigos de estado HTTP registrados: qué significan, cuándo aparecen y dónde están definidos.

100ContinueThe server received the request headers and the client should send the body.
101Switching ProtocolsThe server is switching to the protocol the client asked for in the Upgrade header.
102ProcessingThe server accepted the request and is still working on it.
103Early HintsHeaders sent ahead of the final response so the client can start preloading resources.
104Upload Resumption SupportedThe server supports resuming this upload if it is interrupted.
200OKThe request succeeded.
201CreatedThe request succeeded and created a new resource.
202AcceptedThe request was accepted for processing, which hasn't finished.
203Non-Authoritative InformationSuccess, but a proxy changed the response the origin server sent.
204No ContentThe request succeeded and there is no body.
205Reset ContentSuccess; the client should reset the form or view that sent the request.
206Partial ContentThe response holds only the byte range the client asked for.
207Multi-StatusThe body holds separate status codes for several operations.
208Already ReportedMembers of this collection were already listed earlier in the same 207 response.
226IM UsedThe response is a delta applied to the current instance, not the full resource.
300Multiple ChoicesThe resource has several representations and the client should choose one.
301Moved PermanentlyThe resource has a new permanent URL, given in the Location header.
302FoundThe resource is temporarily at the URL in the Location header.
303See OtherThe result is at another URL, which the client should fetch with GET.
304Not ModifiedThe cached copy is still valid, so no body is sent.
305Use ProxyThe resource must be accessed through the proxy in the Location header.
306(Unused)Reserved; it was once used for Switch Proxy and is no longer used.
307Temporary RedirectThe resource is temporarily at another URL; repeat the request there with the same method and body.
308Permanent RedirectThe resource has moved permanently; repeat the request at the new URL with the same method and body.
400Bad RequestThe server can't process the request because it is malformed.
401UnauthorizedThe request has no valid credentials for this resource.
402Payment RequiredReserved for future use.
403ForbiddenThe server understood the request but refuses to allow it.
404Not FoundThe server has nothing at this URL.
405Method Not AllowedThe resource exists but doesn't support this HTTP method.
406Not AcceptableThe server can't produce a response in any format the Accept headers allow.
407Proxy Authentication RequiredThe client must authenticate with the proxy first.
408Request TimeoutThe server gave up waiting for the client to finish sending the request.
409ConflictThe request conflicts with the current state of the resource.
410GoneThe resource existed but has been removed permanently.
411Length RequiredThe server needs a Content-Length header.
412Precondition FailedA condition in the request headers, such as If-Match, is false.
413Content Too LargeThe request body is larger than the server accepts.
414URI Too LongThe URL is longer than the server accepts.
415Unsupported Media TypeThe server doesn't accept the body's format.
416Range Not SatisfiableThe requested byte range is outside the resource.
417Expectation FailedThe server can't meet the Expect header.
418I'm a teapotA joke code from RFC 2324, kept reserved as "(Unused)" because so much software already recognizes it.
421Misdirected RequestThe request reached a server that can't answer for this host.
422Unprocessable ContentThe request is well formed but its content fails validation.
423LockedThe resource is locked.
424Failed DependencyThe request failed because a request it depended on failed.
425Too EarlyThe server won't process a request that might be replayed.
426Upgrade RequiredThe client must switch to another protocol, named in the Upgrade header.
428Precondition RequiredThe server requires a conditional request, such as one with If-Match.
429Too Many RequestsThe client has sent too many requests in a given time and is being rate limited.
431Request Header Fields Too LargeThe headers, or one header, are too large.
451Unavailable For Legal ReasonsThe resource can't be served for legal reasons.
500Internal Server ErrorThe server hit an unexpected condition.
501Not ImplementedThe server doesn't support the functionality needed, such as the request method.
502Bad GatewayA gateway or proxy got an invalid response from the server behind it.
503Service UnavailableThe server can't handle the request right now.
504Gateway TimeoutA gateway or proxy didn't get a response from the server behind it in time.
505HTTP Version Not SupportedThe server doesn't support the HTTP version of the request.
506Variant Also NegotiatesContent negotiation is misconfigured on the server.
507Insufficient StorageThe server can't store what it needs to complete the request.
508Loop DetectedThe server found an infinite loop while processing the request.
510Not ExtendedThe request needs an HTTP extension the server requires.
511Network Authentication RequiredThe client must authenticate to get network access.
419Page ExpiredLaravelThe CSRF token is missing or expired.
420Enhance Your CalmTwitter (historical)The client is being rate limited.
444No Responsenginxnginx closed the connection without sending a response.
494Request Header Too Largenginxnginx's code for headers over its buffer limits.
495SSL Certificate ErrornginxThe client certificate failed verification.
496SSL Certificate RequirednginxA required client certificate wasn't sent.
497HTTP Request Sent to HTTPS PortnginxA plain HTTP request reached a port that expects TLS.
499Client Closed RequestnginxThe client closed the connection before nginx sent the response.
509Bandwidth Limit ExceededApache / cPanelThe site has used up its bandwidth allowance.
520Web Server Returned an Unknown ErrorCloudflareThe origin server returned something Cloudflare couldn't use.
521Web Server Is DownCloudflareThe origin server refused Cloudflare's connection.
522Connection Timed OutCloudflareCloudflare couldn't establish a TCP connection to the origin in time.
523Origin Is UnreachableCloudflareCloudflare can't reach the origin server.
524A Timeout OccurredCloudflareCloudflare connected to the origin, but it didn't respond in time.
525SSL Handshake FailedCloudflareThe TLS handshake between Cloudflare and the origin failed.
526Invalid SSL CertificateCloudflareCloudflare couldn't validate the origin's certificate.
530Origin DNS ErrorCloudflareCloudflare returns 530 together with a 1xxx error, most often 1016 (origin DNS error).

Select a code

Pick a code from the list to see when it is used, the specification that defines it and a command to try it. Use the arrow keys to move through the list.
64 registered codes · 17 unofficial

¿Qué son los códigos de estado HTTP?

Toda respuesta HTTP empieza con un código de estado de tres dígitos que dice qué le pasó a la petición. El primer dígito indica la clase: 1xx es informativo, 2xx significa éxito, 3xx significa redirección, 4xx significa que la petición estaba mal y 5xx que el servidor falló.

Los códigos están definidos en la RFC 9110, HTTP Semantics, que sustituyó a la RFC 7231 en 2022, y en algunas otras RFC, como la RFC 6585 para 429 Too Many Requests. La IANA mantiene el registro oficial. La RFC 9110 renombró dos códigos: 413 ahora es Content Too Large (antes Payload Too Large) y 422 es Unprocessable Content (antes Unprocessable Entity). Los números y su comportamiento no cambiaron.

Algunos códigos que te vas a encontrar no están en el registro. nginx registra 499 cuando un cliente cierra la conexión antes de que la respuesta esté lista, Cloudflare envía del 520 al 526 cuando no consigue una respuesta válida del servidor de origen, y Laravel envía 419 cuando el token CSRF de un formulario ha caducado. Aparecen aparte, marcados como no oficiales.

El código de estado es lo primero que debe comprobar una prueba de API, porque el resto de la respuesta depende de él. Un 201 Created te dice que un POST creó un recurso nuevo, un 404 que el recurso no existe y un 500 que el servidor falló, en cuyo caso el cuerpo puede ser una página de error en lugar del JSON que esperabas.

Cómo usar esta herramienta

  1. 1Recorre la lista, agrupada del 1xx al 5xx con los códigos no oficiales al final, o fíltrala con los botones de clase.
  2. 2Busca por número, nombre o síntoma, como 404, 5xx, redirect, timeout o un nombre antiguo como Unprocessable Entity. Pulsa / para ir al buscador desde cualquier punto de la página.
  3. 3Selecciona un código, o recorre la lista con las flechas del teclado, para ver qué significa, cuándo aparece, la especificación que lo define y códigos relacionados con los que compararlo.
  4. 4Copia el comando curl de Try it para que el endpoint de estado de testingapis.com devuelva ese código, o copia un enlace: /es/tools/http-status/#429 abre directamente el 429.

Solución de problemas

Un 401 aunque enviaste un token
El token está caducado, mal formado, va en la cabecera equivocada o le falta el prefijo Bearer . La cabecera de respuesta WWW-Authenticate suele indicar cuál. Un 403, en cambio, significa que el token es válido pero no tiene permiso.
Un 415 con un cuerpo JSON
La petición no lleva la cabecera Content-Type: application/json, así que el servidor no trata el cuerpo como JSON. El -d de curl envía application/x-www-form-urlencoded salvo que fijes la cabecera.
Un POST se convierte en GET después de una redirección
Los clientes siguen los 301 y 302 repitiendo la petición como GET y sin cuerpo. Los servidores que necesitan conservar el método deben enviar 307 o 308.
Un 502 o un 504 de un balanceador de carga
El proxy que está delante de la aplicación no recibió una respuesta válida: 502 cuando la aplicación se cayó o cerró la conexión, 504 cuando tardó más que el timeout del proxy. Los logs de la propia aplicación muestran la causa.
499 en los logs de nginx
El cliente se rindió antes de que la respuesta estuviera lista: un usuario se fue de la página, o un cliente o un proxy intermedio agotó su timeout. Lo habitual es que la causa sean peticiones lentas al backend.

Preguntas frecuentes

¿Qué diferencia hay entre 401 y 403?

401 Unauthorized significa que el servidor no sabe quién eres: faltan las credenciales, han caducado o son incorrectas. 403 Forbidden significa que sabe quién eres, pero esa identidad no tiene permiso para hacer eso. Volver a iniciar sesión puede arreglar un 401, no un 403.

¿Una API debe devolver 400 o 422 ante una entrada no válida?

Se usan los dos. Una convención habitual es 400 para una petición que el servidor no puede ni leer, como un JSON mal formado, y 422 para datos bien formados que incumplen una regla, como un campo obligatorio que falta o un email no válido.

¿Qué diferencia hay entre 502, 503 y 504?

Los tres suelen venir de un proxy o un balanceador de carga situado delante de la aplicación. 502 Bad Gateway significa que recibió una respuesta no válida del servidor que tiene detrás, 503 Service Unavailable que el servicio está sobrecargado o en mantenimiento, y 504 Gateway Timeout que el servidor de detrás no respondió a tiempo.

¿Qué código de redirección debo usar?

301 y 308 son permanentes; 302 y 307, temporales. 307 y 308 obligan al cliente a repetir la petición con el mismo método y el mismo cuerpo, mientras que los clientes suelen convertir un POST en GET tras un 301 o un 302. Usa 303 See Other para mandar al cliente a una página de resultados después de un POST.

¿418 I'm a teapot es un código de estado real?

Viene de la RFC 2324, una broma del Día de los Inocentes anglosajón (1 de abril) de 1998 sobre cómo controlar cafeteras. La RFC 9110 lista el 418 como no usado pero reservado, porque muchísimo software ya lo reconoce. No está pensado para errores reales.

¿Cómo pruebo cómo maneja mi app un código de estado concreto?

Llama a un endpoint que devuelva el código que pidas. GET https://api.testingapis.com/api/status/503 responde con un 503 y las cabeceras que suele llevar ese estado, como Retry-After. Funciona cualquier código del 200 al 599.