HTTP Status Codes Explained: 200, 404, 500 and More
What HTTP status codes mean, from 200 and 404 to 500, how the five groups work and how your code should react to each.
Short answer: HTTP status codes are three-digit numbers a server sends back to say how a request went. 200 means OK, 404 means the thing you asked for was not found, and 500 means the server itself failed. The first digit tells the family: 2xx success, 3xx redirect, 4xx client error, 5xx server error.
What do the five status code groups mean?
Range | Meaning | Who should act? |
|---|---|---|
1xx | Informational | Usually nobody; handled by libraries |
2xx | Success | Nobody: use the result |
3xx | Redirection | The client follows a new address |
4xx | Client error | The caller: the request was wrong |
5xx | Server error | The server owner: something broke |
What do 200, 404, 500 and the other common codes mean?
Code | Name | Plain meaning |
|---|---|---|
200 | OK | The request worked and the response has the result. |
201 | Created | A new resource was created, typical after a POST. |
204 | No Content | It worked, and there is nothing to send back, typical after a DELETE. |
301 | Moved Permanently | The address has changed for good; use the new one. |
400 | Bad Request | The server could not understand the request, such as invalid JSON. |
401 | Unauthorized | You are not authenticated: missing or invalid credentials. |
403 | Forbidden | The server knows who you are, but you are not allowed. |
404 | Not Found | No resource at that address. |
429 | Too Many Requests | You are sending requests too fast; slow down and retry later. |
500 | Internal Server Error | A bug or crash on the server. |
502 | Bad Gateway | A server in the middle got a bad reply from another server. |
503 | Service Unavailable | The server is overloaded or down for now. |
How should your code react to status codes?
Python's standard library already knows the names. This runnable script prints each name and a sensible reaction:
from http import HTTPStatus
def what_to_do(code):
if 200 <= code < 300:
return "success: use the response"
if 300 <= code < 400:
return "redirect: follow the new address"
if 400 <= code < 500:
return "client error: fix the request, do not blindly retry"
if 500 <= code < 600:
return "server error: retry later, it is not your request's fault"
return "informational or unknown"
for code in (200, 201, 204, 301, 400, 401, 403, 404, 429, 500, 503):
print(code, HTTPStatus(code).phrase, "->", what_to_do(code))One refinement: 429 is a 4xx error, but the right reaction is to wait and retry, ideally after the delay the server asks for. Servers often say how long in a Retry-After header.
What is the difference between 401 and 403?
401 means "I don't know who you are": log in or send a valid key. 403 means "I know who you are, and you may not do this": logging in again will not help. When you call an AI API, a 401 usually points to a wrong or missing API key, and a 429 to rate limits.
To see where codes appear in a real request, read What is an API, REST API methods and the tutorial HTTP methods, status codes, headers and JSON.
Common mistakes
Returning 200 with an error message in the body. Use a proper 4xx or 5xx code so clients can react correctly.
Using 404 for everything that goes wrong.
Retrying 4xx errors forever. Fix the request instead (except 429 and sometimes 408).
Mixing up 401 and 403.
Key Takeaway
Read the first digit first: 2 worked, 3 moved, 4 your request is wrong, 5 the server has a problem. Then use the exact code to decide what to do next.
Ready to start? Learn HTTP, REST APIs and backend basics, including how to read responses and handle errors in your own code. Begin with the free course Git, APIs and Backend for AI: Beginner.
Related articles
More in APIs and Backend
How to Keep API Keys Safe: .env Files and Secrets
Keep API keys out of your code: use .env files and environment variables, ignore them in Git, and know exactly what to do if a key leaks.
4 min readNov 14, 2026Frontend vs Backend: What's the Difference?
What the frontend and backend of an app are, how they differ, how they talk to each other and why AI calls and secret keys belong on the backend.
3 min readNov 12, 2026What Is JSON and Why Do APIs and AI Use It?
JSON is a simple text format for structured data. See what it looks like, its data types, how to read it in Python, and why APIs and AI apps depend on it.
3 min readNov 6, 2026REST API Methods Explained: GET, POST, PUT, PATCH, DELETE
What each REST API method does, with a to-do list example, typical status codes, PUT vs PATCH, and what safe and idempotent mean.
4 min readNov 4, 2026What Are Git and GitHub? The Difference Explained
Git tracks your code's history on your computer; GitHub hosts it online for sharing and teamwork. Learn the difference, the key terms and your first commands.
4 min readNov 2, 2026What Is an API and How Does It Work?
An API explained with a restaurant analogy, then the real parts: endpoints, methods, JSON, status codes and API keys, with a small Python example.
4 min readOct 31, 2026
Comments
Sign in to join the discussion.

