“Top 10” HTTP Status Code explained you need to know as a Front End Developer

Lama Ibrahim
11 min readMar 27, 2023

--

HTTP status codes are three-digit codes that are returned by web servers to indicate the status of an HTTP request made by a client, such as a web browser or an API client. These codes are included in the response header and provide information about the outcome of the request. The first digit of the status code indicates the general class of response, while the last two digits provide more specific information about the response.

There are five classes of HTTP status codes:

  1. Informational (1xx): These codes indicate that the server has received the request and is processing it. They are used to provide feedback to the client during long-running requests.
  2. Success (2xx): These codes indicate that the request was successful and the server was able to process it. The most common success code is 200 OK, which indicates that the requested resource has been successfully returned in the response.
  3. Redirection (3xx): These codes indicate that the client must take additional steps to complete the request. For example, if a requested resource has been moved permanently, the server might respond with a 301 Moved Permanently status code and redirect the client to the new URL.
  4. Client errors (4xx): These codes indicate that there was an error on the client side, such as an invalid request or missing authentication credentials. The most common client error code is 404 Not Found, which indicates that the requested resource could not be found on the server.
  5. Server errors (5xx): These codes indicate that there was an error on the server side, such as a failure to execute a request or a database connection error. The most common server error code is 500 Internal Server Error, which indicates that an unexpected condition was encountered on the server and it was unable to fulfill the request.

I will talk in detail about these top 10 HTTP status codes based on their frequency of use

1) 200 OK

TL;DR the HTTP status code 200 is a success code that indicates that the requested resource has been successfully retrieved or modified by the server and returned to the client in the response

HTTP status code 200 is a success status code, which indicates that the request was successful and the server has returned the requested resource in the response. In other words, this code indicates that the server was able to process the request and provide the client with the requested information.

When a client makes an HTTP request, the server checks whether the request is valid and whether the requested resource exists. If everything is in order, the server returns a 200 status code along with the requested resource in the response. The resource can be in any format, such as HTML, JSON, XML, or an image file.

In practice, a 200 status code is commonly used for GET and POST requests to retrieve or modify resources. For example, if a user sends a GET request to a web server for a specific webpage, the server responds with a 200 status code and the requested webpage in the response body. Similarly, if a user sends a POST request to update a record in a database, the server responds with a 200 status code if the operation is successful.

2) 201 Created:

TL;DR HTTP status code 201 is used to indicate that a new resource has been successfully created on the server and provides the client with the URL of the newly created resource for future reference.

HTTP status code 201 is a success status code that indicates that a new resource has been successfully created on the server in response to a POST or PUT request. It is often used in RESTful APIs to signal the successful creation of a new resource.

When a client sends a POST or PUT request to the server with data to create or update a resource, the server will process the request and, if successful, return a 201 status code along with the URL of the newly created resource in the response header.

For example, if a user submits a form to create a new blog post on a web application, the server might create a new post in the database and respond with a 201 Created status code, along with the URL of the newly created post in the Location header of the response.

It is worth noting that a 201 status code should only be returned when a new resource is created successfully, and not when an existing resource is updated. If an existing resource is updated successfully, the server should return a 200 OK status code instead.

3) 204 No Content:

TL;DR HTTP status code 204 is a success code that indicates that the server has processed the request successfully, but does not need to return any content in the response body. It is commonly used in scenarios where a client sends a request to the server to perform an action, but the server does not need to return any data as a result of that action.

HTTP status code 204 is a success status code that indicates that the server has successfully processed the request, but does not need to return a response body. In other words, the server has fulfilled the request, but there is no content to send back to the client.

HTTP status code 204 is often used in scenarios where a client sends a request to the server to perform some action, but the server does not need to return any data as a result of that action. For example, a client might send a DELETE request to the server to delete a resource, and the server might respond with a 204 status code to indicate that the resource has been successfully deleted, but there is no content to return.

Another common use case for the 204 status code is in combination with the OPTIONS method, which is used to request information about the communication options available for a particular resource. If the server supports the requested options, it may respond with a 204 status code and provide the available options in the response headers.

4) 304 Not Modified:

TL;DR HTTP status code 304 is used to indicate that the requested resource has not been modified since the last time it was accessed, and that the client should use the cached version of the resource. This can help to improve performance and reduce network traffic, especially in scenarios where resources are frequently accessed and updated.

HTTP status code 304 is a success status code that is used to indicate to a client that the requested resource has not been modified since the last time it was accessed, and that the client should use the cached version of the resource.

When a client requests a resource from a server, it includes an If-Modified-Since header in the request. This header specifies the date and time that the client last accessed the resource. If the server determines that the resource has not been modified since the date and time specified in the header, it will respond with a 304 status code, along with an empty response body.

The 304 status code is commonly used in scenarios where a client requests a resource that it has already cached locally, and the server confirms that the cached version is still valid. By returning a 304 status code, the server informs the client that it can continue to use the cached version of the resource, which can help to reduce network traffic and improve performance.

It’s important to note that when a server returns a 304 status code, it does not include the requested resource in the response body. Instead, the client should use the cached version of the resource that it already has.

5) 400 Bad Request:

TL;DR HTTP status code 400 indicates that the server was unable to process the client’s request due to a malformed or invalid request. The client should carefully check the request parameters and formatting to ensure that they are correct before resending the request.

HTTP status code 400 is a client error status code that indicates that the server was unable to process the client’s request because the request was malformed or invalid in some way.

The 400 status code is typically returned when the server cannot understand or process the request due to missing or invalid parameters, incorrect formatting, or other similar issues. This can happen when the client sends a request that is missing required parameters, or when the client sends a request with parameters that are not recognized by the server.

When a server returns a 400 status code, it will typically include a response body that provides additional information about the error, such as a description of the problem and suggestions for how to correct it. This information can help the client to understand what went wrong with the request and how to fix it.

It’s important to note that a 400 status code is a client error code, which means that the issue with the request is typically due to something on the client side, rather than a problem with the server. As a result, clients should check their requests carefully to ensure that they are properly formatted and include all required parameters before sending them to the server.

6) 401 Not Authorized:

HTTP status code 401 is an authentication error response code in the HTTP protocol. It means that the client making the request is not authorized to access the resource requested.

In other words, when a user tries to access a protected resource such as a webpage or file, the server will require the user to provide valid credentials such as a username and password. If the user fails to provide valid credentials, the server will return an HTTP 401 status code to indicate that the request was not authorized.

Some common causes of HTTP 401 errors include incorrect or expired credentials, insufficient permissions for the requested resource, or the server’s security settings blocking access to the resource.

When an HTTP 401 error occurs, the user will typically be prompted to provide valid credentials to access the resource.

7) 403 Forbidden:

TL;DR HTTP status code 403 indicates that the server understood the client’s request, but refuses to fulfill it due to insufficient permissions or other access restrictions. The server typically includes a response body that provides more information about the error and suggestions for how to proceed.

HTTP status code 403 is a client error status code that indicates that the server understood the client’s request, but refuses to fulfill it. This can happen for a variety of reasons, such as when the client does not have sufficient permissions to access the requested resource, or when the requested resource is restricted or forbidden.

When a server returns a 403 status code, it typically includes a response body that provides additional information about the error, such as a description of why the request was forbidden and suggestions for how to proceed. This information can help the client to understand why the request was denied and what steps they can take to rectify the issue.

It’s important to note that a 403 status code is different from a 401 status code, which is used to indicate that the client needs to authenticate or provide credentials before accessing the requested resource. In contrast, a 403 status code indicates that the client is authenticated, but does not have sufficient permissions to access the requested resource.

8) 404 Not Found:

TL;DR HTTP status code 404 indicates that the server was unable to find the requested resource or document

HTTP status code 404 is a client error status code that indicates that the server was unable to find the requested resource or document. This can happen for a variety of reasons, such as when the URL for the resource is incorrect or when the resource has been removed or deleted from the server.

When a server returns a 404 status code, it typically includes a response body that provides additional information about the error, such as a description of the problem and suggestions for how to proceed. This information can help the client to understand why the requested resource was not found and what steps they can take to locate it.

It’s important to note that a 404 status code is a client error code, which means that the issue is typically due to something on the client side, rather than a problem with the server. Clients should check the URL carefully to ensure that it is spelled correctly and points to the correct resource.

In addition to indicating that the requested resource was not found, a 404 status code can also be used to indicate that a server does not wish to reveal whether a resource exists or not, for security or privacy reasons.

9) 500 Internal Server Error:

HTTP status code 500 is a server error response code in the HTTP protocol. It means that the server encountered an unexpected condition or error that prevented it from fulfilling the request made by the client.

In other words, when a user sends a request to a server, the server may encounter an internal error that prevents it from processing the request as expected. When this happens, the server will return an HTTP 500 status code along with an error message to indicate that something went wrong on the server side.

Some common causes of HTTP 500 errors include problems with server configurations, programming errors in server-side scripts or applications, database connection errors, or insufficient server resources like memory, disk space, or processing power.

When an HTTP 500 error occurs, it is important to investigate the root cause of the problem and fix it as soon as possible. This is because it can indicate that something is seriously wrong with the server and may prevent users from accessing the website or application until the issue is resolved.

10) 502 Bad Gateway

HTTP status code 502 is a server error response code in the HTTP protocol. It means that the server acting as a gateway or proxy server received an invalid response from the upstream server while attempting to fulfill the client’s request.

In other words, when a user sends a request to a server, the server may act as a proxy or gateway to forward the request to another server that can handle it. If the upstream server fails to respond or responds with an invalid or corrupted response, the gateway or proxy server will return an HTTP 502 status code to indicate that it was unable to complete the request.

Some common causes of HTTP 502 errors include server overloading, connectivity issues between the gateway or proxy server and the upstream server, or incorrect configuration of the gateway or proxy server.

When an HTTP 502 error occurs, it is important to investigate the root cause of the problem and fix it as soon as possible. This is because it can indicate that there is a problem with the server infrastructure that needs to be addressed before users can access the website or application again.

Thanks for reading😊 Show some support and follow Me on Twitter 🌍 and Medium.

--

--

Lama Ibrahim

Senior Software Engineer 😎 with a pretty good Experience in the FrontEnd Web Development, and ReactJs.