Skip to main content

What is an HTTP status code?

An HTTP status code (HTTP response code) is a numeric code in the HTTP response that shows how the server finished processing the request.

In simple terms: an HTTP status code is the short result of a request: success, an error, or something else.


Why HTTP codes are needed

HTTP codes are needed so a client (browser, application):

  • understands whether the request succeeded
  • learns why an error occurred
  • knows what to do next (retry the request, show an error, go to another address)

Without codes, the client would have to guess what happened.


Where the HTTP status code is located

An HTTP code:

  • is sent in the HTTP response
  • is located in the first line of the response

Example:

HTTP/1.1 200 OK

Here:

  • 200 is the status code
  • OK is the text explanation

Main groups of HTTP codes

HTTP codes are divided into classes by their first digit:

2xx, Success

The request was completed successfully.

  • 200 OK - everything is fine
  • 201 Created - the resource was created

3xx, Redirection

The client needs to go to another address.

  • 301 Moved Permanently
  • 302 Found

4xx, Client error

A problem with the request.

  • 400 Bad Request - an invalid request
  • 401 Unauthorized - authorization is required
  • 403 Forbidden - access is denied
  • 404 Not Found - the resource was not found

5xx, Server error

The server received a correct request but could not process it.

  • 500 Internal Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable

An important point for an interview

  • 404 is a normal HTTP response, not "the server crashed"
  • 4xx → an error on the client's side
  • 5xx → an error on the server's side

Real-life example

You ask:

"Give me the page"

The server responds:

  • 200 → "Here is the page"
  • 404 → "No such page exists"
  • 500 → "I'm broken, try again later"

Short answer for an interview

Remember this wording:

An HTTP status code is a numeric code in the HTTP response that shows the result of processing the request and reports whether it succeeded or an error occurred.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.