Skip to content

Web & Internet

HTTP Status Codes

O(1) lookup — checking a status code means reading one number. It takes the same amount of time no matter how big the rest of the response is.

The idea, in plain English

A status code is a three-digit number the server attaches to every response. It's like a waiter's one-word summary of how your order went: 'here you go' (200), 'we don't have that' (404), or 'the kitchen caught fire' (500). You don't have to read the whole response to know if it worked. The status code tells you right away.

How it works

  1. 1Codes that start with 2 mean success. The request worked, like 200 OK.
  2. 2Codes that start with 4 mean the client made a mistake. For example, asking for something that doesn't exist gives 404 Not Found.
  3. 3Codes that start with 5 mean the server had a problem while trying to help. For example, it crashed, giving 500 Internal Server Error.
  4. 4Real programs check the status code first. Then they decide what to do next: show the page, show an error, or try again later.

When you'd use it

Every HTTP (HyperText Transfer Protocol) response includes a status code. You'll see them often in browser dev tools, API (Application Programming Interface) responses, and server logs whenever something needs debugging.

Common beginner mistakes

  • Don't assume a page that 'loads' always means success. A 404 or 500 page still loads fine in the browser — it just carries bad news.
  • Beginners often mix up 401 and 403. 401 (Unauthorized) means you're not logged in. 403 (Forbidden) means you're logged in but not allowed.

Try it — edit and run

Click the code to edit · press ⌘/Ctrl+↵ to run

Editable code. Tab and Shift+Tab indent. Press Escape, then Tab, to move focus out of the editor.

Expected output — hit Run to try it
200 (success): OK - here you go
404 (client error): Not Found - we don't have that
500 (server error): Internal Server Error - the kitchen caught fire

Not sure this is the right topic? See the learning paths → or where this leads →