HTTP codes

What is an HTTP code?

An HTTP code is a code that a web server issues in response to a request. They allow the web server to communicate with visitors’ browsers, essentially informing the browser whether everything is ok or there is an issue. While HTTP codes are primarily associated with errors, every request generates a response, which has a specific code assigned to it.

The five types of responses

There are five different types of HTTP responses. Each response type has its own prefix, making it easier to identify.

Information responses – 1xx

Information responses are sent as a confirmation that the web server has understood a request. Information responses are prefixed by ‘1’ and follow the ‘1xx’ convention. An example of an information response is ‘100 Continue’, which indicates that the server has received the headers and is now waiting for the body.

Success responses – 2xx

Success responses are sent as a confirmation that a request has been processed successfully. All success responses are prefixed by ‘2’ and follow the ‘2xx’ convention. An example of a success response is ‘200 OK’, which indicates that an HTTP request was completed successfully.

Redirection responses – 3xx

Redirection responses are sent when the client must take additional steps for a request to be completed. All redirection responses are prefixed by ‘3’ and follow the ‘3xx’ convention. An example of a redirection response is ‘308 Permanent Redirect’, which indicates that a resource was permanently moved and all future requests should be sent to the supplied URI.

Client error responses – 4xx

Client error responses are sent when the client is the cause of the error, such as having sent a bad request. All client errors are prefixed by ‘4’ and follow the ‘4xx’ convention. An example of a client error response is ‘404 Not found’, which indicates that the client has requested a resource that is not available.

Server error responses – 5xx

Server error responses are sent when the server encounters an error that originates from the server’s end. All server error responses are prefixed by ‘5’ and follow the ‘5xx’ convention. An example of a server error response is ‘500 Internal server error’, which indicates that the server has come across an unexpected error.

How do HTTP codes work?

HTTP Codes are part of the HTTP standard, which ensures that browsers and web servers are able to understand them equally. HTTP codes facilitate the communication between servers and browsers through a structured codeset that affirms actions or informs the other party that there is an issue.

Why do we have HTTP codes?

HTTP codes can help administrators troubleshoot issues with their a WordPress website and the web server. Basically you can tell what is wrong with the website. Even when you get a generic, error such as ‘500 Internal Server Error’, there is still a lot to learn from such errors. When using the right tools, and when you know which of the web server log files that WordPress admins have access to you need to look into,  they can help you get to the bottom of the issue faster.

HTTP codes can also be used in SEO (Search Engine Optimization) such as 301 and 302 redirects, which may affect SEO efforts.

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon