MasterServerBlog › 500-internal-error

Error 500 Internal Server Error

← all articles

Error 500 Internal Server Error

The HTTP protocol sometimes returns status 500. It indicates a fault in the server configuration. Formally it reports a system component failure, but in practice the problem is far less global.

The appearance of a 500 Internal Server Error only means that the server itself is running normally, but some requests are not being processed properly.

This error can appear on any web resource without exception. Administrators configure it in advance and define alternative actions in case it occurs.

If you rent a VPS and the message appears too often, that is a clear reason to move to a more powerful server. On the current one, the situation can be fixed by programmers. In that case the code of the site's internal pages needs to be revised and improved.

First: incorrectly assigned file permissions

Each domain uses scripts that run in normal mode.
Error number 500 can occur if the wrong permissions are set on a script.

Consequences: until the issue is fixed, attackers can theoretically make changes to a file with 777 permissions.

How to fix it: set the correct permissions. The recommended value for folders is 755, and for scripts it is 644, not 777.

Preferably, all file permissions in the domain should be set under a single user.

Second: the script runs too long

Besides the execution time PHP allots to each piece of code, the server itself imposes the same kind of limit.
Even if everything is fine from PHP's point of view, the server may report an error - 500 Internal Server Error.

Consequences: if the server receives no response, it considers the job unfinished or potentially unable to complete, so the plugin or script will be terminated.

How to fix it: to prevent the issue from appearing, you need to find and debug the code. Most often, the slow section of code is immediately noticeable during testing. Hosting technical support is not obliged to help you find it, but you can ask the author of the software or site engine for help.

Third: htaccess

The hidden file with this name has strict syntax, and violating it automatically leads to the error. It also happens that you add a directive, format it correctly syntax-wise, but it is simply not supported.

Consequences: the page will not work.

How to fix it: find the htaccess file in the domain's root directory and fix the syntax inside it. If the site still does not work after that, it is recommended to upload a new «clean» file and use it as a replacement for the current one. You can also open the Error.log file. It makes it easy to find the faulty directive and fix it.

Fourth: not enough memory

If your script uses a certain amount of data, the server immediately allocates a certain amount of memory for it. If the script wants more memory and there is none, a 500 error appears.

Consequences: until the memory allowance is increased, the script will keep taking the page down.

How to fix it: since the error appears as a protective measure, you need to check the code for fragments that may be overly demanding, or simply increase the amount of RAM on the server.