Internal Server Error 500, how does it occur and what is the analysis?

This guide helps in finding errors even if the site is working but some parts of it are not. For example, image upload doesn’t work or theme upload, infinite page loading, or anything else. WordPress has enabled error display, and this guide is specifically for that option.

An Internal Server Error can occur for several reasons, such as code errors or .htaccess issues.

Errors appearing on WordPress from the latest version are:

– This web site experiencing technical difficulties
– There has been a critical error on your website.

Resolution comes down to a process of elimination.

If the site is not WordPress (since the WordPress guide is provided later in this article), activate PHP debugging using the following code:

ini_set('display_errors', 1);

Insert this code in the first line right below <?php in each file to detect which file and which line in that file is causing the problem.

First, log into cPanel – File Manager and look for the “error_log” file in public_html (or cPanel > File Manager and the LOGS folder inside it, you will see the “yourdomain.error_log” file). Check what it says inside, which file is causing the problem, and where the error is in the code. It should also show the date the error occurred; if it’s a recent date, it’s possible that this error is causing the 500 error, if not, keep looking.

Check the .htaccess file. It’s possible that it’s not written correctly or that an error has occurred somewhere. It’s best to revert the .htaccess file to its initial state. Instead of deleting lines of code from the file, it would be better to add a pound sign (#) at the beginning of the line, and by doing so, you will “delete” it, meaning that line will no longer be relevant.

WordPress Error Detection

WordPress Debug link

Through this link, you will find instructions on how to activate the option that will help you display the error location.

Before starting, change the PHP version to ea-php74, and if that solves the problem, then that’s it. If not, continue with this guide. Change PHP version.

Each step of this guide must be completed to find the problem.

If the site where you have the problem is the main domain on the hosting account, its wp-config.php file is located: in cPanel > File Manager > public_html

If the site where you have the problem is an Addon domain (an additional domain on hosting), its wp-config.php is in another folder, not in the public_html folder. You can find the main folder (document root) by going to cPanel and clicking on Addon domain, and below the Document Root field, the path to your site’s folder will appear, which is also a link. Clicking on it will immediately open your site’s folder containing the wp-config.php file.

domainscpanel Internal Server Error 500, how does it occur and what is the analysis?

Right-click on the wp-config.php file and select edit (if a small window opens, just click on the edit button). When it opens, find the line that says:

define( 'WP_DEBUG', false );

Umesto te linije treba da ubacite ovo:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 1 );

Simply copy-paste and save in the top right corner.

Next, look at the debug log file in your site’s folder (in the same place as the wp-config.php). There is a wp-content folder, and inside it, a debug.log will appear.

debuglog Internal Server Error 500, how does it occur and what is the analysis?

If it’s not there, open the site a few times to display the error, then refresh the folder by clicking reload, and it will appear. If it still doesn’t show up, then you are in the wrong folder, or you haven’t done the first part of the guide on enabling the debug option in the wp-config.php file.

Now let’s move on to reading the errors. To open it, right-click and select “view.”

If you see something like:

[05-Feb-2019 13:38:17 UTC] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 65536 bytes) in /home/username/public_html/wp-content/plugins/everest-forms/includes/class-evf-log-levels.php on line 14
[05-Feb-2019 13:39:33 UTC] PHP Fatal error:  Allowed memory size of 41943040 bytes exhausted (tried to allocate 32768 bytes) in /home/username/public_html/wp-content/plugins/jetpack/locales.php on line 236

That means that the plugin caused the problem. In this case, two plugins: everest-forms and jetpack.

But only if it says PHP FATAL ERROR, if it says warning, then it’s not the cause.

There are two ways to solve this issue in this case: either delete the problematic plugin and replace it with another one that doesn’t cause problems (in this case, it can disrupt the site depending on the plugin and its purpose).

In this specific example, the issue can be resolved through cPanel’s MultiPHP INI Editor by increasing the memory_limit. You can set it to double the value shown or, for example, 256MB to ensure you won’t have any problems.

I mentioned this example because it is the most common error that you can easily solve with just two clicks.

It is also possible to solve the problem by changing the PHP version from the MultiPHP Manager in cPanel, as some plugins work with different PHP versions. If something doesn’t work with newer versions like 7.4 (at the time of writing this article) or higher, it is certainly not safe to use that plugin.

If the error log file does not show anything, then the error is in the .htaccess file. You can solve this by simply modifying the .htaccess file and returning it to the default state. The content that should be present only in that file for WordPress to work is as follows:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Scroll to Top