Understanding HTTP Status Codes
An HTTP status code is a server response to a browser’s request. When you visit a website, your browser sends a request to the site’s server, and the server then responds to the browser’s request with a three-digit code: the HTTP status code
.
The first digit of each three-digit status code begins with one of five numbers, 1 through 5; you may see this expressed as 1xx or 5xx to indicate status codes in that range. Each of those ranges encompasses a different class of server response.
Importance of HTTP Status Codes
HTTP Status codes are a vital part of web development and every web developer needs to learn about them. These status codes represent a discussion between your browser and the server on the internet. They communicate when anything is amiss, when things are touch and go, or when everything is fine between the two. You can diagnose site issues quickly to reduce downtime by understanding status codes and knowing how to use them. Some of these status codes can even be used to make it easier for users and search engines to find your website; a 301 redirect
, for instance, notifies users and bots that a page has moved permanently to a new location.
These status codes are also important for SEO (Search Engine Optimization). Search engine bots see HTTP status codes while they’re crawling your site. In some cases, these messages can influence if and how your pages get indexed, as well as how search engines perceive the health of your site.
Types of HTTP Status Codes
The HTTP Status Codes are divided into five types. They are listed below.
- Informational Status Codes (1xx)
- Successful Status Codes (2xx)
- Redirection Status Codes (3xx)
- Client Error Status Codes (4xx)
- Server Error Status Codes (5xx)
There are an overwhelming number of status codes, but we will learn about the most important ones only!
Informational Status Codes
Informational status codes indicate that the request from the client has been initiated by the server.
Status Code | Meaning |
---|---|
100 Continue | Indicates that the client should continue the request or ignore the response if the request is already finished. |
101 Switching Protocols | Indicates the protocol the server is switching to. |
102 Processing | Indicates that the server has received and is processing the request, but no response is available yet. |
103 Early Hints | Primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a response |
Successful Status Codes
Successful status codes indicate that the request received by the server from the client has been successfully processed or completed.
Status Code | Meaning |
---|---|
200 OK | The request succeeded. The result meaning of "success" depends on the HTTP method. |
201 Created | The request succeeded, and a new resource was created as a result |
202 Accepted | The request has been received but not yet acted upon. |
203 Non-Authoritative Information | This response code means the returned metadata is not exactly the same as is available from the origin server but is collected from a local or a third-party copy |
204 No Content | This response means that there is no content to send for this request, but the headers may be useful. |
205 Reset Content | Tells the user agent to reset the document that sent this request. |
Redirection Status Codes
Redirection status codes indicate that the server received the request, but further action is needed to enable the completion of that particular request. This usually happens when a webpage has been moved temporarily or permanently to another address.
Status Code | Meaning |
---|---|
300 Multiple Choices | The request has more than one possible response |
301 Moved Permanently | The URL of the requested resource has been changed permanently. The new URL is given in the response. |
302 Found | This response code means that the URI of the requested resource has been changed temporarily. |
303 See Other | The server sent this response to direct the client to get the requested resource at another URI with a GET request. |
307 Temporary Redirect | The server sends this response to direct the client to get the requested resource at another URI with the same method that was used in the prior request. |
308 Permanent Redirect | This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response header. |
Client Error Status Codes
Client error status codes indicate that the request has been received by the server but it cannot proceed because it may contain incorrect syntax.
Status Code | Meaning |
---|---|
400 Bad Request | The server cannot or will not process the request due to something that is perceived to be a client error |
401 Unauthorized | This status code indicates that the request made by the client is password protected and requires credentials, such as a username and password, to access. If incorrect credentials were provided, this error code will still be generated. |
403 Forbidden | This status code implies that the page requested by the client is inaccessible. |
404 Not Found | This status code implies that the requested resource is not available on the server. |
408 Request Timeout | This means that the request from the client is taking more time than expected to reach the server. |
Server Error Status Codes
Server error status codes indicate when the request is valid but it contains an error so the the server is unable to fulfill the request.
Status Code | Meaning |
---|---|
500 Internal Server Error | The server has encountered a situation it does not know how to handle. |
501 Not Implemented | The request method is not supported by the server and cannot be handled. |
502 Bad Gateway | This error response means that the server while working as a gateway to get a response needed to handle the request, got an invalid response. |
503 Service Unavailable | This status code indicates that due to the overloaded server, the request sent by the client cannot be handled at the moment. |
504 Gateway Timeout | This error code indicates that the server is acting as a gateway or a proxy, and did not actually receive the desired response on time. |