HTTP Status Codes
web http backend api
What are HTTP Status Codes?
HTTP status codes are like quick messages that websites send back to tell you what happened with your request.
They’re three-digit numbers that tell you if everything worked (200s), if you need to go somewhere else (300s), if you made a mistake (400s), or if the website had a problem (500s).
Simple Analogy
Think of HTTP status codes like getting responses from a friend:
2xx (Success): “Yes, I can help!”
- 200 OK: “Here’s what you asked for!”
- 201 Created: “I just made this new thing for you!”
- 204 No Content: “I did what you asked, but there’s nothing to give back.”
3xx (Redirect): “You need to ask someone else…”
- 301 Moved: “I don’t have that anymore, but my friend does. Go ask them.”
- 302 Found: “I have it, but it’s over there right now. Go look there.”
4xx (Client Error): “You made a mistake…”
- 400 Bad Request: “I don’t understand what you’re asking for.”
- 401 Unauthorized: “You need to tell me who you are first.”
- 403 Forbidden: “I know who you are, but you’re not allowed to have this.”
- 404 Not Found: “I don’t have what you’re looking for.”
- 418 I’m a Teapot: “I’m a teapot, I can’t make coffee!” (This is a real joke code!)
5xx (Server Error): “I made a mistake…”
- 500 Internal Server Error: “Something went wrong on my end, sorry!”
- 502 Bad Gateway: “I asked someone else for help, but they gave me bad information.”
- 503 Service Unavailable: “I’m too busy right now, try again later.”
- 504 Gateway Timeout: “I asked someone else for help, but they took too long to answer.”
Key Concepts
- 2xx Codes: Everything worked! (Success)
- 3xx Codes: You need to go somewhere else (Redirect)
- 4xx Codes: You made a mistake (Client Error)
- 5xx Codes: The website made a mistake (Server Error)
- Common Codes: 200 (OK), 404 (Not Found), 500 (Server Error)