You probably encountered a situation where, when trying to enter the site instead of the desired page, it gave the error 404, 503, 500, 403. What do all those magic numbers mean, and what should the site owner do if users encounter them? Solve all the mysteries in this material.
A bit about HTTP status codes
First, a little basic theory. When you visit a website, your browser sends an HTTP request to the server hosting the site. Each HTTP request received by the server gets an HTTP status code – a three-digit number. But the number is not simple; it’s remarkable – it belongs to one of five classes of states:
4**: client-side errors;
5**: errors on the server-side.
This article will focus on error classes 4**, 5** and tell you how to solve them if your site is hosted on shared hosting.
HTTP status codes in class 4** indicate that the problem was caused by the user visiting the site (for example, by browser problems or typographical errors in the links). However, it’s always good to know what kind of error the user has encountered – the problem might actually be on the site. And class 5** codes are returned by the webserver when it encounters an error and probably can’t handle the client request.
Let’s see what the site administrator can do to solve common errors when accessing a web resource.
400: Bad Request
The code “Invalid request” means that there is a syntax error in the HTTP request. A few examples of when this can happen and what actions you should take:
User has corrupted cookies – advise cleaning cache and cookies.
Internal browser error – you can try upgrading or reinstalling the browser.
A typo when manually typing a request (for example, in console commands like wget or curl).
The “Not Authorized” code appears when there are problems with authentication or authorization on the site. For example, the visitor is trying to view his online store profile but has not entered his username and password or has entered them incorrectly. In this case, a 401 response code is sent until the visitor provides the correct credentials.
If the error does not go away, the site administrator should check that the .htpasswd file containing the user’s login credentials is intact.
The “Forbidden” site connection error indicates that the visitor has no access to the requested resource, file, or page. This situation usually occurs for a variety of reasons:
- No permissions to open the files. Make sure the user has the rights to read the file (chmod command to help you).
- Access denied in .htaccess. You may have restricted access to the site to some IP addresses in the .htaccess file.
- There is no index file in the requested directory. Try to create an index file or enable directory listing in the webserver configuration.
404: Not Found
Perhaps the most well-known error that most Internet users have encountered. It means that the server cannot find the requested resource, or, to put it simply, “this page does not exist”.
If you are sure that the error 404 on the site should not occur, check the link for typos and ensure that the page file is not moved or deleted. The problem can also be a lack of user access to the folder where the file is located – to enable it; you need to add read and execute permission for the directory.
500: Internal Server Error
“Internal server error” often appears when the failure cannot be attributed to any other known class 5** error. A site error code 500 means that the problem most likely lies in the server settings.
The most common causes of failure are:
- An error in the .htaccess file. Try renaming it and check if the website is working.
- Lack of necessary packages, incorrectly selected version of PHP. Possibly you should change the PHP version or install the required modules.
- A bug in the site code. If it worked before, restore the site from a backup copy.
502: Bad Gateway
If error 502 occurs regularly, you should contact your web hosting provider’s technical support service when opening the site. Describe in detail the actions that lead to the problem and specify the time at which it was detected (if you contact QuantumHost’s technical support)
The code “Service unavailable” on shared hosting means that the limit on the number of HTTP requests has been exceeded (you can read about all limits in the hosting specifications). This error may occur if your code makes many calls to images, stylesheets, and other files when generating the page. Possible solutions – either optimize the code, reduce the number of HTTP-queries, or switch to a more effective hosting plan or consider moving those intensively used websites to a Cloud VPS.
504: Gateway Timeout
The error can be decoded as “server response time has expired.” It occurs when the webserver cannot receive a response from the site in a set amount of time.
This usually happens when the site scripts take too long to execute (e.g., database uploads). In this case, you can bypass the webserver and access the site through port 8081 (for sites running on the ISPmanager control panel) or 8080 (for cPanel and Plesk), or 2222 (for DirectAdmin). If you want to configure the intervals for waiting for the site response manually, it can be done only on VPS, where more flexible server settings are available.
Now you know what errors can occur on the client and server sides, where to look for problems, and how to troubleshoot them. There are many more HTTP status codes, and we have listed only the most basic ones.
Also, don’t forget that if you can’t fix any problem with your site, you can search for a solution in our Knowledge Base or contact Technical Support – we are always ready to help.
If you know of any other possible solutions for the errors mentioned in this article, please post them in the comments.