HTTP-Statuscodes

Alle registrierten HTTP-Statuscodes: was sie bedeuten, wann sie auftreten und wo sie definiert sind.

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

Was sind HTTP-Statuscodes?

Jede HTTP-Response beginnt mit einem dreistelligen Statuscode, der sagt, was mit dem Request passiert ist. Die erste Ziffer gibt die Klasse an: 1xx ist informativ, 2xx bedeutet Erfolg, 3xx Weiterleitung, 4xx heißt, der Request war fehlerhaft, und 5xx, dass der Server versagt hat.

Die Codes sind in RFC 9110 definiert, HTTP Semantics, der 2022 RFC 7231 abgelöst hat, und in einigen weiteren RFCs wie RFC 6585 für 429 Too Many Requests. Die IANA führt das offizielle Register. RFC 9110 hat zwei Codes umbenannt: 413 heißt jetzt Content Too Large (früher Payload Too Large) und 422 Unprocessable Content (früher Unprocessable Entity). Nummern und Verhalten haben sich nicht geändert.

Manche Codes, die dir begegnen, stehen nicht im Register. nginx protokolliert 499, wenn ein Client die Verbindung schließt, bevor die Response fertig ist, Cloudflare schickt 520 bis 526, wenn es vom Ursprungsserver keine brauchbare Antwort bekommt, und Laravel schickt 419, wenn das CSRF-Token eines Formulars abgelaufen ist. Sie sind separat aufgeführt und als inoffiziell markiert.

Der Statuscode ist das Erste, was ein API-Test prüfen sollte, weil der Rest der Response von ihm abhängt. Ein 201 Created sagt dir, dass ein POST eine neue Ressource angelegt hat, ein 404, dass es die Ressource nicht gibt, und ein 500, dass der Server versagt hat. Dann kann der Body eine Fehlerseite sein statt des erwarteten JSON.

So benutzt du dieses Tool

  1. 1Blättere durch die Liste, gruppiert von 1xx bis 5xx mit den inoffiziellen Codes am Ende, oder filtere sie mit den Klassen-Buttons.
  2. 2Such nach Nummer, Name oder Symptom, etwa 404, 5xx, redirect, timeout oder einem früheren Namen wie Unprocessable Entity. Mit / springst du von überall auf der Seite ins Suchfeld.
  3. 3Wähle einen Code oder bewege dich mit den Pfeiltasten durch die Liste, um zu sehen, was er bedeutet, wann er auftritt, welche Spezifikation ihn definiert und welche verwandten Codes du zum Vergleich ansehen solltest.
  4. 4Kopiere den curl-Befehl unter Try it, damit der Status-Endpoint von testingapis.com diesen Code zurückgibt, oder kopiere einen Link: /de/tools/http-status/#429 öffnet direkt die 429.

Fehlerbehebung

Ein 401, obwohl du einen Token geschickt hast
Der Token ist abgelaufen, fehlerhaft, steckt im falschen Header oder es fehlt das Präfix Bearer . Der Response-Header WWW-Authenticate sagt oft, was davon. Ein 403 bedeutet dagegen, dass der Token gültig ist, aber die Berechtigung fehlt.
Ein 415 bei einem JSON-Body
Dem Request fehlt der Header Content-Type: application/json, deshalb behandelt der Server den Body nicht als JSON. -d in curl schickt application/x-www-form-urlencoded, außer du setzt den Header.
Ein POST wird nach einer Weiterleitung zum GET
Clients folgen 301 und 302, indem sie den Request als GET ohne Body wiederholen. Server, die die Methode erhalten müssen, sollten 307 oder 308 senden.
Ein 502 oder 504 vom Load Balancer
Der Proxy vor der Anwendung hat keine gültige Antwort bekommen: 502, wenn die Anwendung abgestürzt ist oder die Verbindung geschlossen hat, 504, wenn sie länger als das Timeout des Proxys gebraucht hat. Die Logs der Anwendung selbst zeigen die Ursache.
499 in den nginx-Logs
Der Client hat aufgegeben, bevor die Response fertig war: Ein Nutzer hat die Seite verlassen, oder ein Client bzw. vorgeschalteter Proxy ist ins Timeout gelaufen. Meist sind langsame Backend-Requests die Ursache.

Häufige Fragen

Was ist der Unterschied zwischen 401 und 403?

401 Unauthorized bedeutet, dass der Server nicht weiß, wer du bist: Zugangsdaten fehlen, sind abgelaufen oder falsch. 403 Forbidden bedeutet, dass er weiß, wer du bist, diese Identität aber das nicht darf. Neu anmelden kann ein 401 beheben, kein 403.

Soll eine API bei ungültiger Eingabe 400 oder 422 liefern?

Beides ist verbreitet. Eine übliche Konvention: 400 für einen Request, den der Server gar nicht lesen kann, etwa fehlerhaftes JSON, und 422 für korrekt aufgebaute Daten, die gegen eine Regel verstoßen, etwa ein fehlendes Pflichtfeld oder eine ungültige E-Mail.

Was ist der Unterschied zwischen 502, 503 und 504?

Alle drei kommen meist von einem Proxy oder Load Balancer vor der Anwendung. 502 Bad Gateway heißt, er hat vom Server dahinter eine ungültige Antwort bekommen, 503 Service Unavailable, dass der Dienst überlastet ist oder gewartet wird, und 504 Gateway Timeout, dass der Server dahinter nicht rechtzeitig geantwortet hat.

Welchen Redirect-Code sollte ich verwenden?

301 und 308 sind dauerhaft, 302 und 307 vorübergehend. 307 und 308 verlangen, dass der Client den Request mit derselben Methode und demselben Body wiederholt, während Clients nach einem 301 oder 302 aus einem POST meist ein GET machen. Nimm 303 See Other, um einen Client nach einem POST auf eine Ergebnisseite zu schicken.

Ist 418 I'm a teapot ein echter Statuscode?

Er stammt aus RFC 2324, einem Aprilscherz von 1998 über die Steuerung von Kaffeemaschinen. RFC 9110 führt 418 als ungenutzt, aber reserviert, weil so viel Software ihn bereits kennt. Für echte Fehler ist er nicht gedacht.

Wie teste ich, wie meine App mit einem bestimmten Statuscode umgeht?

Ruf einen Endpoint auf, der den gewünschten Code zurückgibt. GET https://api.testingapis.com/api/status/503 antwortet mit einem 503 und den Headern, die dieser Status normalerweise mitbringt, etwa Retry-After. Jeder Code von 200 bis 599 funktioniert.