Web4 min read10 interview questions
HTTP status codes in plain words
The three-digit numbers a server sends back, and what each group means.
In one sentenceA status code is the server's short answer to your request: it worked, you should go elsewhere, you made a mistake, or we made a mistake.
Think of it like thisIt is like a shop assistant saying "here you go", "it moved to aisle 5", "we do not stock that", or "sorry, our system is down".
The big picture
Tap any step to see where to use it, how to use it and an example result.
Read the first digit
Everything starting with 2 means success. 3 means "look somewhere else". 4 means the request had a problem, so the fault is on the sender's side. 5 means the server had a problem.
- 2xx: success
- 3xx: redirect
- 4xx: client error
- 5xx: server error
The ones you will meet most
200 means OK. 301 means the page moved for good. 400 means the request was badly formed. 401 means you need to sign in. 403 means you are signed in but not allowed. 404 means not found. 429 means you made too many requests. 500 means the server broke. 503 means it is temporarily unavailable.
Why it matters for you
When you build APIs, the right code tells other developers what went wrong without reading your docs. When you debug, the first digit tells you whether to look at your request or at the server.
Common mistakes
- Returning 200 with an error message inside. Use a real error code instead.
- Mixing up 401 (not signed in) and 403 (not allowed).
- Using 500 for mistakes the caller made. Those are 4xx.
Quick recap
- 2xx worked, 3xx redirect, 4xx you, 5xx server
- 404 is not found and 403 is not allowed
- 429 means slow down
- Pick the code that tells the truth
Try it yourself
Visit a page that does not exist on any site and look at the Network tab to see the 404. Then try the same on an API you use.
Top 10 interview questions
Ordered from basic to advanced. Try answering out loud first, then open the answer.
What are the five groups of HTTP status codes?Basic
1xx informational, 2xx success, 3xx redirection, 4xx client error (the request was wrong), and 5xx server error (the server failed).
What is the difference between 200, 201 and 204?Basic
200 means OK with a response body. 201 means something was created, typically after a POST. 204 means success with no body to return, common for deletes.
What does 404 mean, and what is 410?Basic
404 means the server cannot find that resource. 410 Gone says it existed but was removed on purpose and will not return, which tells search engines to drop it.
What is the difference between 401 and 403?Basic
401 means you are not authenticated: the server does not know who you are. 403 means it knows who you are, but you are not allowed to do this.
What is the difference between 301 and 302 redirects?Intermediate
301 is permanent, so browsers and search engines remember the new address. 302 is temporary, so the original address stays the official one. 307 and 308 are the stricter versions that keep the HTTP method unchanged.
When would an API return 400, 422 or 409?Intermediate
400 for a malformed request, 422 when the request is well formed but fails validation rules (for example an invalid email), and 409 when it conflicts with the current state, such as creating something that already exists.
What does 429 mean and how should a client react?Intermediate
Too many requests: you hit a rate limit. The client should slow down and retry later, ideally honouring the Retry-After header and using exponential backoff.
What is the difference between 500, 502, 503 and 504?Intermediate
500 is a generic server error. 502 means a gateway got a bad reply from the server behind it. 503 means the service is temporarily unavailable or overloaded. 504 means the gateway waited too long for the server behind it.
How do 304 Not Modified and ETags save bandwidth?Advanced
The browser sends the ETag or date of its cached copy. If the file has not changed, the server answers 304 with no body and the browser reuses its copy, so only a tiny response travels.
How would you use status codes when designing an API and monitoring it?Advanced
Return the most specific accurate code so clients can react correctly, never 200 with an error inside. For monitoring, alert on the rate of 5xx for server problems and watch 4xx spikes, which often point to a broken client, an expired token or an attack.
Guides are simplified on purpose. Tool names and details change, so check the official documentation before relying on a detail.