What is an HTTP Status Code?

One of the things that make the internet so easy to use is the fact that, most people do not have to think about what goes on in the background. You start up your computer, type in a web page or domain name and it takes you to where you want to go, at least, most of the times. But sometimes, a weird message pops up, telling you that your request cannot be completed or that you have a bad gateway, etc.

Employers generally provide an IT specialist to fix the problem, but what if you do not have an IT person to run to? What do you do? Contact your web hosting provider or website designer? How do you fix the problem yourself? Start by understanding what these messages mean and what causes them, which is exactly what this post aims to help you do.

What is an HTTP Status Code?

 If you’ve ever gotten an error code while using the internet, you are familiar with what a Hypertext Transfer Protocol – HTTP status code is. Officially though, it is defined as a standard response code that a website server gives on the internet to assist in identifying what’s causing a problem when a web page, for example, does not load properly.

In a nutshell, an HTTP status code tells you when an HTTP request was successfully completed. The official registry of HTTP status codes is maintained by the internet The Internet Assigned Numbers Authority-IANA.

Browser error code or internet error codes are the same things as an HTTP status. In reality, they are just others given names for it. Furthermore, the HTTP Status Line and HTTP Status Code are also used interchangeably, HTTP is however more common.

Another thing to note is that the HTTP Status Line is made up of an HTTP status code and an HTTP reason phrase. For example, the HTTP status line 400: Bad Request is made up of the HTTP status code 400 and Bad Request is the HTTP Reason Phrase.

HTTP status code response values range from 1xx to 5xx. The first digit explains the class of response. There is no categorisation role assigned to the last two digits.

There are more than 40 different server status codes, but less than a dozen feature regularly on your browser. Understanding what each code means can help website owners identify and fix issues, highlighted by the code, most of the time.

5 Types of HTTP Status Code Responses

Responses are placed in five categories or class:

1. Informational

Codes beginning with 1, followed by two other digits, are Informational. These codes indicate that the request was received and the process has not ended.

An example of this is code 100 – Continue. It says the server has received only a part of your request, but you should continue with the request unless you are told that it’s rejected.

2. Success

A success response means the request was successfully received, understood, and accepted. Success responses are marked by 2, with the two additional digits.

OK, Created, Accepted, Non-authoritative Information, No Content, Reset Content and Partial Content are the different types of success responses with each assigned a number from 200 to 206. A 201 Created response, for example, just means that the request is done and a new source has been created.

3. Redirection

 A Redirection response says that, in order to finish the request, further action must be taken.

The status code for Redirection Responses is 3 plus the other two stipulated numbers.

302 Found and 307 Temporary Redirect are examples of a redirect response. They both mean that the page requested was temporarily moved to a new URL.

Before moving on to the two final codes on our list, let’s do a quick review of the status quotes outlined.

Codes 1xx to 3xx are informational, confirm success or order a redirection, respectively. They are not error codes, so they won’t pop up on your browser. However if you want to see the status codes that the browser doesn’t generally show, there are different tools that you can use to make this possible and easy. The next two codes are error codes and the most popular of the five groups. Like the other classes listed above, there are a host of server codes that exist within them. Each code has a special and unique meaning.

4. Client Error

A client error code means the request has incorrect syntax or cannot be filled for some other reason; usually it’s the web surfer’s fault. Client error codes take the status code 4xx and there are approximately 17 error codes that fall under the Client Error group.

Some of these codes include the 408- the server timed out waiting for the rest of the request from the browser. There are a number of reasons why a 408 status code would be generated. One example is if there is net congestion that causes the loss of data packets between the browser and the server. This would prevent the server from getting the full request sent by the browser leading to the code being sent.

Another example of the status codes within the client error group, is the 410. It means, “the requested resource is gone and won’t be coming back.” This is similar to the 404 – Not Found, but unlike the 404, the 410 lets you know that the situation is expected and permanent. This brings us to the three most common client error HTTP status codes:

  • 400 -Bad Request
  • 403 -Forbidden
  • 404 -Not Found

400 Bad Request

This status code is generated when the server cannot or will not process a request. It happens when the web user did something wrong. The user’s error could range from a malformed request syntax, deceptive request routing or invalid request message framing, among a host of other things.

403 Forbidden

A 403 status code is created when the server is ‘flexing its muscles.’  It receives your request, understands it, but refuses to authorise it. The error code tells you that access to the page or resource you are trying to reach is absolutely forbidden. There are three main reasons access would be denied:

  • Empty http docs directory
  • No index page
  • Permissions and ownership errors

404 Not Found

The 404 not found error simply means the server could not find  the web page or resource you were looking for. Three main reasons that would prompt this response:

  • Page moved, but the URL did not change and does not match it.
  • Page totally removed; deleted.
  • Client entered incorrect URL

In simple terms, a 404 Not Found error tells you that the webpage you’re looking for does not exist with the URL you entered.

5. Server Error

The final HTTP Error group is the Server Error which generates the 5xx status code. Let’s look at the 500 Internal Server Error Code for example. It is a very general code that can be customised based on the website owner’s preference, but it always means that something has gone wrong on the site’s server and because the server can’t tell you what the specific problem is, it just says that there is an internal server error. There are several things that could cause this code to be generated. Some of them include:

  • Faulty PHP
  • Third-party plugins
  • A break in the connection to the database.

Another common status error code is the:

502 – Bad Gateway.

This is generally a where one server gets an invalid response from another. In some instances, the server will cancel or kill a request since it took too long will take too long and the connection to the database breaks prompting the 502 Bad Gateway code.

Summary

Every time your browser interacts with the server, HTTP status code messages are generated. Sometimes you see them and often not at all. As such, understanding them is important, especially if you are a website owner or developer, because you will have an idea of how to fix the problem, when they show up.