Web & APIs

HTTP status code

An HTTP status code is the little 3-digit number a server puts at the top of every web response to tell you, in one glance, how the request went. You've already met the famous ones: 200 means 'OK, here you go,' 404 means 'I couldn't find that,' and 500 means 'something broke on my end.' Every page you load and every API call you make comes back stamped with one of these.

The first digit sorts them into five families, which is the only part worth memorizing. 2xx = success (it worked). 3xx = redirect (look over there instead). 4xx = you messed up (bad request, not found, not allowed). 5xx = the server messed up (it's not your fault). So even a code you've never seen — say 429 — you can read at a glance: 4-something, so the problem is on the asking side (it means 'too many requests, slow down').

When you're debugging, the status code is the first thing to check. A 401 tells you it's a login problem; a 404 tells you the address is wrong; a 500 tells you to stop poking your code and go read the server's logs. It's the server's one-word answer to 'how did that go?'

$ curl -I https://example.com/missing
HTTP/2 404

# 2xx ok · 3xx go elsewhere · 4xx your fault · 5xx server's fault

The first digit tells you almost everything: 4xx means the problem is on your side.

Mnemonic: 4xx is 'you,' 5xx is 'them.' Don't fix your code over a 500 until you've read the server logs.

Also called
status coderesponse code200404500http code
See also