Quite often, hosting owners suffer from the constant occurrence of a 500 (Internal Server Error) error message. She, as it is called, simply poisons life for many. Now we will try to briefly understand the essence of the situation itself and see how we can get rid of the error in the future.
Internal Server Error: what is it?
So, let's start with the very meaning of this phrase. In the system (catalog) of Windows errors (and not only) there is an error number 500, which corresponds to the computer term Internal Server Error. The translation of this phrase means an internal server error related to the status of the HTTP protocol.
Essentially, the error means that the server software is either not working, or it is working, but one or more of its components are failing in the form of refusal on client requests, such as a search engine or Internet browser.
Causes of the error
Speaking of the Internal Server Error in thein a broad sense, it should be borne in mind that it can occur on many sites or resources written using completely different CMS. Here, by the way, it is necessary to distinguish between the causes of its occurrence.
Very often this situation can be observed on sites like WordPress, OpenCart, Joomla, etc. If management structures like WordPress are not used when building a site, the reason may lie in the fact that hosting itself fails during connecting the wrong PHP extensions, or the site after the request returns incorrect HTTP headers that cannot be recognized by your server.
An equally common cause of the Internal Server Error is the lack of correct access rights. So, for example, if in PHP the script files that are hosted have access rights of 777, it may very well be that their execution is simply blocked by the server, as a result of which an error message is issued.
Also, one of the reasons may be that the scripts take a long time to complete. The fact is that PHP execution time limits apply not only to hosting, such limits can also be set from the server side. In other words, it is somewhat like an operation timeout. When the server does not receive a response to a request for a certain time, it simply blocks the execution of the script.
In some cases, the Internal Server Error error may appear when the hosting has exceeded the limit of used memory. Simply put, the script forexecution requires more than it should, and after all, such a limit is set not only for PHP, there are often restrictions on the consumption of resources by all executable scripts.
Finally, one of the most common situations in which an Internal Server Error occurs is the content of incorrect directives in the.htaccess file (by the way, this is most often seen when working with the WordPress engine). Now we have come close to finding a solution for each specific situation.
Internal Server Error: how to fix it in simple ways
First, let's see what we can do if we encounter invalid permissions. In this case, access rights 777 allow absolutely everyone to edit the content, which undoubtedly affects security. In such a situation, you need to change them by applying the value 755 to folders, 600 to script files, and 644 to all steel data files.
If the executable script runs too long, you can try to increase the waiting time, however, there is one catch. Such a solution can work on a dedicated server or VPS (Virtual Private Server), and in the case of virtual hosting, there will be no effect.
As for the overestimated memory consumption in comparison with the restrictions in force on the hosting, here we can only advise you to contact the support service or simply change the hosting provider itself, whose restrictions will not be so severe.
Now a few words about the.htaccess file. The fact is that it involves the use of a very strict syntax, if errors or some inaccuracies were made during the settings, it will not be possible to avoid the Internal Server Error. Here you need to do the following. First you need to check the presence of the file itself in the root directory of the site, after which, after making a backup copy, delete it completely and completely. If after such a procedure the site becomes operational again, then the problem is in the.htaccess file, which will have to be checked for errors in the syntax.
Problems with the WordPress engine
WordPress is worse. The fact is that this engine is able to overwrite the original.htaccess file responsible for managing access to hosting files and folders, and the original file should be created only once, and especially not in WordPress!
The easiest way to fix this situation is to disable the WordPress theme and use any other theme instead. If the error has disappeared, it’s the theme itself, if not, you need to gradually disable WordPress plugins and check which one affects performance.
In some cases it may be necessary to update WordPress to the latest version and disable the file overwrite feature. To begin with, we download the original.htaccess file to the computer terminal, then we enter the folder on the site along the path /wp-admin/includes/, followed by downloading the misc.php file, which must be opened, say, instandard Notepad (or any other text editor) and find the function line "function save_mod_rewrite_rules". Now in the function itself, go to the line "return insert_with_markers($htaccess_file, 'WordPress', $rules);" and replace it with "return true;" (of course, all commands are written without quotes). It remains only to save the changes and upload the new file to the hosting with the replacement of the old file misc.php.
The only downside to this method is that it disables WordPress updates in this case. When plug-ins are connected, they will, of course, not work.
In principle, these are, so to speak, the most common causes of an error and methods for its elimination. In fact, there can be a lot of reasons that there can be a lot of ways to deal with such situations, so you will have to analyze the situation in each specific case, and only then choose which method to use to correct the error.