HTTP (Hypertext Transfer Protocol) is a process through which clients interact and communicates. When someone clicks a link or writes an URL their browser provides a request to the server for getting information.
When you access a web server or an application, every HTTP request that you receive gets triggered with an HTTP status code. HTTP status codes are basically three digit codes and contain 5 different classes. It can easily be identified with the 1st digit like:
- 1xx: Informational
- 2XX: Success
- 3XX: Redirection
- 4XX: Client Error
- 5XX: Server Error
This mainly deals with the identifying and troubleshooting several HTTP error codes like 4xx and 5xx status codes. It comes from a system administrator’s perspective. You will face several such scenarios where you will see that web server responds to a request with a certain error code. Therefore, in this article, we will provide the main causes and solutions to these common error codes.
Client and Server Error Overview
Client Errors or HTTP Status Codes from 400 to 499 is caused by the HTTP requests sent via user client. These errors are basically client related. However, it becomes very essential to know how the users are tackling these error codes to identify the important issues. Obviously, it will help you to figure out the essential fixes through server configuration.
There are several errors returned by the web server when it is sure that it has encountered some errors. Otherwise, it might happen that it is unable to process the request.
Basic Troubleshooting Methodology
- When you are using a web browser to test the web server, then refresh the browser after several changes.
- Go through the server logs to get more details about the server handling.
- HTTP status code definitions are basically implemented by the application that is involved in serving several requests. It signifies that the actual server code which it returns depends on how the server software solves the particular error. This will obviously help you on the right path. Let’s have a look at some of the encountered errors that govern the entire understanding HTTP status codes.
400 Bad Request
400 Status Code or Bad Request error is basically the HTTP request that was sent to the server containing invalid syntax.
Some of the situations you might face when a 400 Bad Request error occur:
- The users get associated with the corrupted site. Cleaning the browser’s cache and cookies however solve this issue.
- The malformed request occurs owing to the defective browser.
- A malformed request can sometimes occur due to human intervention while forming HTTP requests manually.
- Try to open the same webpage in a separate browser.
- Clean the cache and check if there is any security updates.
- However, if you face this issue frequently your P.C or Mac should be checked thoroughly.
401 status code error generally occurs when the user is trying to access the resource without having a proper authentication. It might happen that the user should give credentials in order to see the protected sources.
In order to combat the issue, please go through the below steps
- If you are a Website owner, just add same password protection to your site. Else you change part of it through a cPanel account.
- Go for the Password Protect Directories tab present inside the Scrutiny Menu Box.
- Then select the web folder you need to protect.
- It will provide a good security layer to prevent access to your admin area.
The 403 request generally occurs when the user is making a valid request but the server is not accepting the request. It happens due to lack of information to access the requested resource. If you are facing this error there are some of the causes
403 error usually occurs when the user does not have the appropriate authority to read the file.
Index File Not Existing
It also occurs when the user is trying to access a directory which does not contain a default index file. Also, the directory listing is disabled there. For Example, Suppose the user wants to access the link http://example.com/emptydir/ and emptydir directory does not contain any index file. In that case, 403 status will be returned.
In order to make your directory listing enabled, you have to access the web server configuration. You can checkout a detailed guide to fix 403 Forbidden Error
404 Not Found
The 404 Status Code or Not Found Error mainly signifies that the user can communicate with the server, but unable to spot the requested file or resource.404 error occur in different situations. If the user is encountering 404 Not Found Error, there might be a list of questions while troubleshooting-
- Does the link that directed the user contain a typographical error in it?
- Did the user write the incorrect URL?
- Does the file exist in a particular location? Was the resource deleted on the server?
- Whether the server configuration contains the latest document root location?
- Is there any symbolic link that the resource is accessing? If yes, please make sure that the web server is integrated to follow the symbolic links.
Try to fix this issue by following the below steps
- Refresh the webpage by pressing F5 on the keyboard.
- Make sure that the URL does not contain any error.
- Perform entire cleaning of your browser cache.
- Modify the DNS server.
500 Internal Server Error
The 500 status code or the Internal Server Error mainly occurs when the server cannot proceed with the requesting owing to some unanimous reason. Moreover, this code can appear when some particular 5xx errors get more prominent. The most common cause of this particular error is server misconfiguration or may be missing packages from the server end.
Quick steps to Fix it:
- Please go through the websites .htaccess file. Ensure that it is properly built.
- Make sure that there is no incorrect permission on files and folders.
502 Bad Gateway
502 status code mainly occurs when a particular server is a gateway or proxy server. Also, it occurs when if it doesn’t receive any valid response from the backend that meets the request.
However, if the server is a reverse proxy server like a load balancer, check the below things.
- The backend servers should be healthy.
- Proper reverse proxy configuration along with appropriate backend specifications.
- There should be a healthy network connection between backend servers and reverse proxy server. If the server interacts through ports, please ensure that the firewall is permitting traffic between them.
- If your web application has a proper configuration through the socket, make sure that the location of the socket is correct and it is providing permissions.
An Easy Solution:
- Make an attempt to reload the URL by just pressing F5 on the keyboard.
- Start with a new browser session.
- Close all the browser windows and then begin with a fresh session.
- Also, disable your CDN for the time being.
- Now restart your network requirements.
503 Service Unavailable
503 Status code or 503 Service Unavailable Error occurs when the server is extra loaded or under maintenance. This error signifies that the service must be available at certain points.
However, if the server is not under maintenance this will signify that the server does not contain sufficient CPU or memory resources to tackle all the incoming requests. Otherwise, the web server needs to be configured to permit more users, threads as well as processes.
Just follow the below basic steps
- Try to refresh or reload the URL by just clicking on Ctrl +R. Else Press F5.
- Make an attempt to restart the router and modem and also the device.
504 Gateway Time Out
The 504 Status Code usually occurs when the server is a gateway or a proxy server. Therefore, it does not receive a response from the backend server within the stipulated time period.It occurs due to the following situations
- When the network connections between the servers are weak.
- The backend server which involves fulfilling the request is very slow owing to weak performance.
- Gateway server’s timeout duration is very short.
We hope this blog covers all the major areas pertaining to HTTP error codes and it’s fixed. This article will give you a brief insight into the HTTP codes and it’s suitable fixes. However, feel free to get in touch with us in case of any queries.