HTTP status codes

beginnerFoundations

TL;DR

Every HTTP response carries a three-digit status code. The first digit is the category (2xx worked, 3xx redirect, 4xx you did something wrong, 5xx the server did). During a test the exact code often tells you more than the page content does.

What it is

When your browser or your tools ask a web server for something, the server answers with a status code: a three-digit number saying how the request went. You already know 404. There are many more, and they follow a simple pattern.

How it works

The first digit sorts every code into one of five families:

RangeFamilyMeans
1xxInformationalReceived, still going. Rare day to day.
2xxSuccessIt worked. 200 OK, 201 Created, 204 No Content.
3xxRedirectGo elsewhere. 301/302, 304 Not Modified.
4xxClient errorYour request was wrong or not allowed.
5xxServer errorThe server broke trying to handle it.

How to test with them

The codes that earn their keep are usually 4xx and 5xx, because they leak how the app thinks:

Seeing the raw code with curl:

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/

Reference: MDN’s full status code list.

← Back to Foundations