HTTP common errors and their meaning explained




The most common error message a normal person surfing the web will encounter is error 404. However, for those in the web business, further understanding of the HTTP errors will help to improve user experience(UX), reduce bounce rate and improve ranking in the search engine pages.

In this tutorial, we will explore what the error codes meant and how to response to them when you(website owner) encounter one.

Classes of status code


Whenever the web server bumps into an error or an event occurred, it will generate a status code that comes in 3 digit numbers. The first digit represent the status code purpose. For example :

1XX - informational purposes

2XX - indicates success

3XX - for redirection

These status codes that starts with 1 to 3 will not generate any error page that will stop the process or pause the user. They usually ended in a log file or pass to search engine crawler and internet browser for further actions.

If the web server encounters error that need immediate attention, we will see the 4XX and 5XX type of status codes.

4XX - client-side(internet browser, FTP-client, etc) errors

5XX - server-side trouble.

These 4XX - 5XX status codes WILL stop the process immediately until the problem has been rectified. We will explore further on what cause these status codes to be generated and what you can do about it.

Client-Side Errors (4XX)


400 – Bad Request

When a visitor issues a command with bad HTTP syntax to the web server or the client(browser) sends in a request that the server is unable to comprehend or process. The web server will generate 400 bad request page. How to fix this? Check the web server log file for the malformed HTTP command. Usually, the client needs to upgrade the browser or perform thorough scanning to check for security issue.

401 – Authorization Required

Ok, this is not an error per se, but rather the client is trying to access a protected page and the server replies back with a 401 - Authorization Required status code. The web server will prompt the client to enter the username and password before allowing the client access.

See https://www.socketloop.com/tutorials/golang-basic-authentication-with-htpasswd-file

403 – Forbidden

Alright, basically the web server is working as advertised. The client is not allowed to enter the page. There is nothing wrong with the HTTP syntax or client-side issue. Simply denied access by the web server. Perhaps for security reason - to protect sensitive material from being exposed or indexed by search engine crawler, maybe the web master decided to hide a dead body inside the page or directory.

IF you are the web master and use Apache HTTP server, you can include these lines in the .htaccess file to protect the directory and generate 403 status code whenever someone try to enter the page or directory

 # Don't listing directory
 Options -Indexes
 ErrorDocument 403 http://www.your-website-home-page.com/or-directory

404 – Not Found

Yup, this the most common HTTP status code that normal people would know or hear about it. Basically, the requested page cannot be found by the web server and it returns the 404 page.

Usually, this is caused by typo on the client side or the file/page no longer reside on the web server. To fix this problem, the visitor has to check if the URL is correct without any typo and the web master needs to check if the page/file is indeed there. Again, check the web server log file for further information.

408 – Request Time-Out

Hello server! you there? 408 request time-out occurs whenever the request sends in by the client takes too long for the server to process and reply back. There's nothing much the client can do but to repeat the request again. The usual culprit of this request time-out is that the web server couldn't handle the load, being DDOS, run out of memory, run out of disk space, etc. The web master needs to check the I/O load, put in DDOS protection such as CloudFlare and probably need to restart the web server.

410 – Gone

Similar to 404, but 410 means that the web server didn't find the requested file and is very certain about the file going missing. It was done intentionally by the web master where as comparing to 404 - it means the file is somewhere... just that the web server didn't know where to find it because of typo.

Will 410 status codes impact your web site ranking? Yes, if you are the web master, make sure to remove the URLs that generated 410 - Gone status code with the Google Webmaster Tools(now known as Google Search Console) to prevent user entering a page with 410 - Gone status code and this will reduce your website's bounce rate.

Google Search Console Remove URLs tool

These are the most common HTTP error status codes that you will encounter. If you are looking for more detailed and in-depth explanation for other 4XX status codes. See https://en.wikipedia.org/wiki/ListofHTTPstatuscodes#4xxClientError

Server Errors (5XX)


500 – Internal Server Error

Probably a web master most common friend whenever some unexpected server-side error occurs. 500 - internal server error could be caused by variety of reasons, such as a line of PHP code WITHOUT the terminating ;, missing database table field or column, mis-configuration in the Apache/Nginx/PHP-FPM/Golang etc configuration or missing environment variables or corrupt WordPress plugin.

What can you do if you are a visitor? Try clearing the cache and reload the page. If it stills that same, take a screen shot together with the URL that is causing the 500 - internal server error and alert the web master.

What can you do if you are the web master? Visit the page with that cause the 500 server error and tail the log files to see further information on what is causing the error to happen. If you have access to the source code, chances are you can repair the problem yourself. If the offending file is a binary file, you will need to escalate this issue to the developer or software supplier.

502 – Bad Gateway

Somehow the gate where the request from the client has to go through before reaching the server has gone bad. This problem usually occurs when the web server is sitting behind a gateway or upstream server such as a proxy.

What can you do as a client? Nothing. Just have to wait for the web master or or the gateway techies to fix the connection issue. There was case where an under sea earth quake near Taiwan severed the connection from Asia to US. Internet connection to web servers based in US encountered 502 - bad gateway status codes until the traffic was rerouted through Europe and Africa.

503 – Service Temporarily Unavailable

Whenever a web server cannot handle the load or powered down for the scheduled maintenance, chances are a visiting client will see a 503 - service temporarily unavailable. Nothing to panic about and this status code will go away after a while.

If you are webmaster, it is important to monitor your web server resource usage. Do you see any CPU or memory usage spike? You might need to do some audit or performance tuning to your web server. IF the number of visitors have increases, maybe it is time to upgrade the web server resources as well.

Also, do check for null attacker or DDOS attacks.

Reference :

https://en.wikipedia.org/wiki/ListofHTTPstatuscodes





By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.


Advertisement