Developer Tools

HTTP status codes: the five families, and the dozen you will actually meet

Nobody needs to memorise sixty codes. Learn the five families by their first digit and a dozen common ones, and you can read almost any error message, API response or browser warning.

By the Toolcloak team8 October 20263 min read
In this article
  1. The five families
  2. The dozen you will meet
  3. Tell them apart
  4. 502, 503, 504: the gateway trio
  5. For people who build things

Every time a browser or app asks a server for something, the server answers with a three-digit number before it sends anything else. That number is the status code. It is the shortest honest summary of what just happened.

The five families

Read the first digit
1001xx InformationalHold on, keep going
2002xx SuccessIt worked
3013xx RedirectionLook somewhere else
4044xx Client errorThe request was the problem
5005xx Server errorThe server was the problem

If you can only remember one thing, remember that 4 and 5 split the blame between asker and answerer.

The dozen you will meet

CodeNameWhat it really means
200OKRequest worked and here is the result
201CreatedSomething new was made, such as a new record
204No ContentWorked, with nothing to send back
301Moved PermanentlyThis address is gone for good. Update your links
302FoundTemporarily elsewhere. Keep using the old address
304Not ModifiedNothing changed, use your cached copy
400Bad RequestThe request was malformed
401UnauthorizedYou are not logged in or the credentials are wrong
403ForbiddenLogged in, but not allowed
404Not FoundNothing lives at this address
429Too Many RequestsSlow down: you hit a rate limit
500Internal Server ErrorThe server crashed handling a good request
503Service UnavailableOverloaded or down for maintenance

Names follow the standard. “Unauthorized” is a historic misnomer: it really means unauthenticated.

Search any status code and get a plain-English meaning with an example.Open HTTP Status Code Lookup

Tell them apart

Four codes people confuse
401 UnauthorizedWe do not know who you are. Log in or send valid credentials.
403 ForbiddenWe know who you are. You are not allowed here.
301 Moved PermanentlyUpdate your bookmarks and links. Search engines move the ranking to the new address.
302 FoundUse the new address this time only. The old one stays the main one.

Mixing up 301 and 302 is a classic SEO mistake. A temporary redirect does not hand over the old page's standing in the same way.

502, 503, 504: the gateway trio

You, the front door and the app behind it
  1. 1YouSend a request to the website
  2. 2Front door (proxy or load balancer)Passes it to the real application
  3. 3The applicationDoes the work, or fails to

Each of these three codes is the front door telling you what it saw happen to the application.

  • 502 Bad Gateway: the front door got a broken or invalid answer from the app.
  • 503 Service Unavailable: the app is too busy or switched off on purpose. Try again soon.
  • 504 Gateway Timeout: the app took too long, so the front door gave up waiting.

For people who build things

  1. Use the right code. A wrong password is 401, not 200 with an error message inside.
  2. Do not send 200 for failures. Monitoring tools and caches read the code, not your message.
  3. Be honest about 404 and 410. 410 Gone tells search engines the page was removed on purpose.
  4. Return 429 with a Retry-After header so clients know when to try again.

Questions people ask

What do the first digits of HTTP status codes mean?

1xx informational, 2xx success, 3xx redirection, 4xx client error and 5xx server error.

What is the difference between 401 and 403?

401 means you are not authenticated: log in or send valid credentials. 403 means you are authenticated but not permitted to do this.

What is the difference between 301 and 302?

301 is a permanent move and passes the old page's standing to the new one. 302 is a temporary redirect, and the original address stays the main one.

What causes a 502, 503 or 504 error?

502 means the gateway got a bad response from the app, 503 means the app is overloaded or down, and 504 means the app took too long to answer.

Should an API return 200 for errors?

No. Use the appropriate 4xx or 5xx code so clients, caches and monitoring can tell that something failed.