HTTP responses and status codes
You have probably encountered a 404 Not Found page. On a worse day, you may have seen 500 Internal Server Error.
Those numbers are HTTP status codesConcept · lights on your mapstatus codeThe three-digit summary a server includes in every response: 2xx succeeded, 3xx go elsewhere, 4xx the request was wrong, 5xx the server failed. The first digit alone narrows the investigation.: three-digit codes a server includes in its response to summarize what happened to the request.
A status code gives the client a quick answer: did the request succeed? Does the client need to do something else? Was the request itself the problem? Or did the server fail?
Learning the main status-code families allows you to understand the outcome of many web requests before examining any deeper technical details.
What is an HTTP response?
An HTTP response is the structured message a server sends back after receiving and handling a request.
A simplified response might look like this:
HTTP/1.1 200 OKContent-Type: application/json{"order_id": 1042,"status": "confirmed"}The first line is called the status line: HTTP/1.1 200 OK. The status code lives there, between the HTTP version and a short description.
Like a request, the response can also contain headers and a body.
In this example, the server successfully retrieved an order and returned information about it as JSON.
Status-code families
HTTP status codes are grouped into families according to their first digit.
- 1xx: The request is still progressing.
- 2xx: The request succeeded.
- 3xx: The client must go somewhere else or take another step.
- 4xx: The request cannot be fulfilled in its current form.
- 5xx: The server failed while attempting to handle a valid request.
You do not need to memorize every code; the goal is to recognize the families and learn a few common examples. So the next sections look closely at the ones you will meet most often.
2xx: the request succeeded
Codes beginning with 2 indicate that the request was handled successfully.
The most familiar example is: 200 OK
A 200 response generally means: the request succeeded, and here is the result.
It is the common success code behind page loads, data retrieval, API calls, and many other operations.
However, 200 is not the only successful status code. 201 Created, for example, commonly means that the request succeeded and a new resource was created.
If a coffee application successfully creates a new order, its server might return 201 Created rather than 200 OK.
For beginner-level recognition, remember: 2xx means success.
3xx: redirects
Codes beginning with 3 commonly tell the client that the requested resource can be found somewhere else.
This is called a redirectConcept · lights on your mapredirectA 3xx response saying the requested resource is somewhere else, with the new address in a Location header. The browser follows it automatically. Used for moved pages, HTTP-to-HTTPS upgrades, shortened links, and login flows..
A simplified response might look like this:
HTTP/1.1 301 Moved PermanentlyLocation: https://coffeeapp.com/new-menuThe browser can then automatically send a new request to that address.
Redirects are commonly used when:
- A page or an entire domain moves, and old links should keep working
- A shortened link forwards to its full destination
- A website sends users from HTTP to HTTPS
- A user is sent to a login page
Common redirect codes include 301, 302, 307, and 308, which differ in whether the move is considered permanent and how the next request should be made.
You do not need to memorize those differences yet. The concept to keep is: 3xx means the client is being directed somewhere else.
4xx: the request cannot be fulfilled as sent
Codes beginning with 4 indicate that the server cannot fulfill the request in its current form, and people often call these client errors, although that does not necessarily mean the person using the application did something wrong.
The most famous member of the family is 404 Not Found. The server was reached and understood the request, but could not find anything at that path. If order 9999 does not exist, GET /orders/9999 may come back as a 404, whether the URL was mistyped, the link points to an old location, or the record was deleted or never there. (A server may also deliberately hide whether a protected resource exists.)
More generally, the problem might come from:
- An invalid URL
- Missing required information
- An expired login token
- Insufficient permission
- A malformed request created by the client application
Other common examples include:
400 Bad Request: the request is invalid or cannot be understood401 Unauthorized: authentication is missing or invalid403 Forbidden: the requester is recognized but not allowed to perform the action429 Too Many Requests: the client has exceeded a rate limit
You do not need to memorize all of these yet; authentication, authorization, and rate limits will appear later.
For now, remember: 4xx means the server rejected or could not fulfill the request as it was sent.
The client may need to change the request, provide credentials, wait, or request something else.
5xx: the server side failed
Codes beginning with 5 indicate that the server or supporting systems could not successfully complete the request.
The best-known member is 500 Internal Server Error. The request reached the server, and something went wrong while the server was handling it. The cause might be an unhandled exception, a failed database operation, incorrect configuration, a software bug, or a dependency behaving unexpectedly. Rather than exposing those internal details, the server returns the general 500, so engineers may need to inspect logs, traces, and monitoring information to determine what actually happened.
Other examples include:
502 Bad Gateway: one server received an invalid response from another system503 Service Unavailable: the service is temporarily unable to handle the request504 Gateway Timeout: one system waited too long for another system to respond
These codes become especially important in applications made of many connected services, where a server may be operating correctly itself but unable to complete the request because another service failed.
For beginner-level recognition, remember: 5xx means the server side could not complete the request.
Status codes are summaries, not full explanations
A status code gives a useful high-level result, but it does not tell the complete story.
A 404 tells you that something was not found, but not necessarily why.
A 500 tells you that the server encountered a problem, but not which line of code failed.
A response body may contain additional details:
HTTP/1.1 400 Bad RequestContent-Type: application/json{ "error": "Drink size is required." }The status code identifies the general category, while the body provides more specific information that the client or user may need.
Engineers often examine both.
Reading a complete response
Imagine that the coffee app sends the order request from the previous lesson:
POST /orders HTTP/1.1Content-Type: application/json{ "drink": "latte", "size": "large" }HTTP/1.1 201 CreatedContent-Type: application/json{ "order_id": 1042, "status": "confirmed" }You can read the exchange as: the client submitted a new order. The server successfully created it and returned the new order’s information.
If the drink size were missing, the server might instead return: HTTP/1.1 400 Bad Request
If the order system unexpectedly failed, it might return: HTTP/1.1 500 Internal Server Error
The request and response together form one complete web interaction.
Using status codes to understand failures
When something fails, the status-code family provides an immediate clue about where to begin investigating. The first digit tells you which side of the conversation to suspect.
A 4xx response suggests examining the request:
- Was the path correct?
- Was required data missing?
- Was the user logged in?
- Did the user have permission?
- Was the request rate-limited?
A 5xx response suggests examining the server and its dependencies:
- Did the application throw an exception?
- Was the database available?
- Did another service time out?
- Was the server overloaded?
- Was something configured incorrectly?
This does not always reveal the root cause, but it narrows the investigation.
Triage like an engineer. Whose side of the conversation has the problem?
The mental model to remember
An HTTP response is the structured message a server returns to a client.
A status code is a three-digit summary of how the request went.
The first digit identifies the family:
- 2xx: success
- 3xx: redirect or further action
- 4xx: the request cannot be fulfilled as sent
- 5xx: the server side failed to complete the request
The three most important individual codes to recognize are:
- 200 OK: the request succeeded
- 404 Not Found: the requested resource could not be found
- 500 Internal Server Error: the server encountered an unexpected problem
You should now be able to look at a status code and determine whether the request succeeded, was redirected, was rejected, or failed on the server side.
Monitoring shows the site's responses are suddenly 30% 500s. A colleague asks what that means in plain words. You say:
▼ answer the check to continue ▼