HTTP status codes

The list of all HTTP status codes, their name, and their meaning.

loading HTTP status codes
About this tool

What are HTTP status codes?

Every HTTP response starts with a three-digit number, the status code, that tells the client what happened to its request. 200 means it worked, 404 means the resource was not found, 500 means the server failed. The first digit gives the class: 1xx informational, 2xx success, 3xx redirection, 4xx the client made a mistake, 5xx the server failed. The codes and their meaning are defined by the HTTP specification (RFC 9110) and the registry kept by IANA.

You need the table in two moments. The first is when something breaks and the browser, curl, a log or a monitoring alert only gives you a number: what does 422 mean, and is it my request or the server? The second is when you design an API or a site and have to choose the code to return: should a missing item be 404 or 410, an invalid JSON 400 or 422, a redirect 301 or 308? A precise code lets clients, caches and search engines behave correctly.

This page lists every code the tool knows, grouped by class, each with its official name and a plain description in your language. It works in your browser and nothing you search is sent anywhere. You can search by number, name or words from the description, copy a code as text, and copy a link that opens the page on that exact card, so you can paste /http-status-codes#418 in a ticket or a code review.

How to look up an HTTP status code

  1. Open the page and type in the search box. The text can be a number (404), a name (teapot), or a word from the description (timeout, redirect). Accents do not matter, and case does not matter either.
  2. With three digits, the result is that one code. With fewer digits it lists every code that starts with them, so 4 shows all the client errors.
  3. With words, the names that match come first and then those that match only in the description. If you type several words, a code has to contain all of them.
  4. Read the card: the number and the name are the title and the description explains when the server uses it. A code that comes from WebDAV, an extension of HTTP, is marked as such.
  5. Use the copy button on a card to copy the number with its name (404 Not Found) for a commit message or a ticket.
  6. Use the # button to copy a link to that card. Anyone who opens it lands on the page with that code highlighted.

Examples

Which one: 401, 403 or 404?

CodeWhen to use itWhat the client should do
401There is no valid credential (missing or expired token, wrong password)Authenticate and try again
403The credential is valid but does not have permissionAsk for access; logging in again will not help
404The resource does not exist (or you prefer not to reveal that it does)Check the address

The name 401 Unauthorized is misleading: it is about authentication. A 401 must come with a WWW-Authenticate header that says how to authenticate. For the credentials themselves, see the JWT decoder and the basic auth generator.

Which redirect: 301, 302, 307 or 308?

CodePermanent?Method of the next request
301YesClients may change POST to GET
302NoClients may change POST to GET
307NoMust keep the same method and body
308YesMust keep the same method and body

For moving a page to a new address, use 301 (or 308 for an API that receives POST). Search engines carry the old address over to the new one. For a temporary redirect, 302 or 307.

502, 503 or 504 in front of your application

502 Bad Gateway: a proxy or load balancer got an invalid reply from your server. 503 Service Unavailable: the server cannot take the request now (overload, maintenance) and may send Retry-After. 504 Gateway Timeout: the proxy waited for your server and gave up. In practice: 502 is "the app crashed or answered nonsense", 504 is "the app is too slow", 503 is "the app asked for time".

400, 409 or 422 for a bad request body

Use 400 when the request cannot even be read, such as JSON with a missing bracket; the JSON formatter shows where. 422 when the JSON is valid but a field is not (an e-mail without @); RFC 9110 calls it Unprocessable Content (formerly Unprocessable Entity, which the search still finds). 409 when the data is fine but conflicts with the current state, such as a username already taken.

Common mistakes with status codes

  • Returning 200 with an error message in the body: clients, caches and monitoring believe it succeeded. Use a 4xx or 5xx with the details in the body.
  • Using 404 for everything that goes wrong: split it. 401 for no login, 403 for no permission, 404 for not found, 410 for permanently removed.
  • Using 500 for the client's mistakes: a bad request body is 400 or 422, not 500. A 5xx should mean that you have a bug to fix.
  • Redirecting a POST with 301 or 302 and losing the body: some clients turn the next request into a GET. Use 307 or 308 to keep the method.
  • Sending 415 and not knowing why: the server does not accept the type of the body. Compare the Content-Type of your request with the valid types, listed in MIME types.

Frequently asked questions

What does status 404 mean?

404 Not Found: the server has no resource at that address, but may have one in the future. If it was removed on purpose and permanently, 410 Gone says it more precisely.

What is the difference between 401 and 403?

401 means "I do not know who you are" and 403 means "I know who you are and you may not do this". Retrying a 401 after authenticating can work; retrying a 403 with the same account will not.

Why does the page list 418 I'm a teapot?

It started as an April Fools' joke in RFC 2324 (the Hyper Text Coffee Pot Control Protocol, 1998): a teapot refuses to brew coffee. The number stays reserved, and some sites return it on purpose.

What does 429 mean and what should I do?

429 Too Many Requests means that you passed the rate limit. Wait the time in the Retry-After header if there is one, and slow down with a retry that doubles the delay each time. A very long address can also end in 414 URI Too Long; the URL parser shows which part is big.

Doing it in code

JavaScript (Node, Express)

app.get('/items/:id', (req, res) => {
  const item = find(req.params.id);
  if (!item) return res.status(404).json({ error: 'Item not found' });
  res.status(200).json(item);
});

Python

from http import HTTPStatus

print(HTTPStatus(404).phrase)       # Not Found
print(HTTPStatus.NOT_FOUND.value)   # 404

Go

package main

import (
	"fmt"
	"net/http"
)

func main() {
	fmt.Println(http.StatusText(404)) // Not Found
	fmt.Println(http.StatusNotFound)  // 404
}

Bash

# Only the status code of a request
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/
Report a problem