Find and Fix 500 Internal Server Error WordPress!

Sometimes it happens that your favorite website suddenly has a Error 500 Internal Server Error spends This is annoying. Above all, this usually happens when you least need it. And even better: it catches you if you “don’t” have a backup at hand.

HTTP 500 Internal Server Error WordPress

First the good news: 99% of the time your work is not gone. Your data is safe in your database, we just can’t access it at the moment.

Why is this happening? Well, this error can be caused, among other things, by a canceled update, a defective plugin, or a server that is too weak. The most common causes of the error in WordPress are:

  • Bad .htaccess: Set code is wrong.
  • PHP memory limit: A process exceeds memory.
  • PHP timeout: A script tries to access (external) resources and takes too long (timeout).
  • Permission error: Permissions of the main files and folders are incorrect.
  • error in the code: Scripts are broken. Paths are set incorrectly.

Sometimes the pages go back after 20 minutes because the server itself then canceled open processes and restarted them. Sometimes this doesn’t work… Either way, you should find the cause of the error so that it can be fixed or avoided in the future.

Error 1: htaccess

As soon as the .htaccess file contains an error, WordPress throws an error 500. This error is easy to fix.

Log into your server via FTP, go to the main WordPress directory (where the wp-login.php file is located) and rename the .htaccess file.

Now clear the cache from your browser and reload the page. The page should load correctly. Once you log in as admin and save the DASHBOARD > SETTINGS > GENERAL page, WordPress will create a new .htaccess file.

The standard file contains the following code:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

If the error isn’t fixed, we’ll have to investigate further.

Mistake 2: PHP Memory Limit

The second reason for a 500 error is usually that the server could not perform the necessary arithmetic operations. WordPress itself is resource hungry. If plugins and themes are added, the server has to do a lot.

Minimum server requirement WordPress
https://wordpress.org/about/requirements:

PHP 5.6 (besser PHP 7 oder höher)
MySQL 5.5 (oder höher)
The mod_rewrite Apache module

PHP Minimum Requirement Themes:

post_max_size 256M
memory_limit 256M
max_execution_time 180
upload_max_filesize 256M
max_input_time 600
max_input_vars 5000

Customize .htaccess

If possible, adjust the .htaccess file. This is located in the WordPress root directory (where the wp-config.php file is also located) and can be edited with a simple text editor. Add the following code to the end of the file:

<IfModule mod_substitute.c>
SubstituteMaxLineLength 10M
</IfModule>

You can also try to increase the PHP memory limit via .htaccess. Add this code to the file:

# PHP Memory Limit
php_value memory_limit 256M

Customize wp-config.php

You can make the adjustments via your hoster account. You can often define the memory limit yourself via the wp-config file.

From the root folder of your WordPress installation, load the wp-config.php file onto your computer. Add the following code right after the opening PHP tag:

define('WP_MEMORY_LIMIT', '256M');

Save the file and upload it back to the WordPress directory. Replace the old file. Clear the cache from your browser and reload the page.

Error 3: Defective plugins

If the above adjustments are unsuccessful, we must continue troubleshooting. Please proceed as follows: Deactivate all plugins. When the page loads, activate the plugins one by one to find the culprit.

If you can’t log in, rename the plugin folder. This will automatically disable all plugins.

Error 4: File Permissions

Permissions usually do not account for the 500 error. But incorrect permissions can cause processes to loop or go nowhere, pushing the server to capacity.

Open your FTP program (e.g. Filezilla) and click on the various folders and subfolders in the main level. Basically, the rights 755 or 644 should be entered here as “Permission”. Deviations can cause problems.

Error 5: Corrupt WordPress files

Sometimes WordPress itself can have bugs. This sometimes happens after a WordPress update, for example when an installation has failed. You can also correct this error quickly.

First download a fresh WordPress installation: https://de.wordpress.org/download/

Unzip the file and re-upload the wp-admin and wp-includes folders. Replace the old folders. Don’t worry: this personal data is somewhere else. Only the pure WordPress data is included here.

After uploading, clear the cache from your browser and reload the page.

Ask your host

The last tip sounds a bit strange now. But if all the measures have not brought a solution, please contact your hoster. This can read the so-called LOG-FILES and in this way find out where the error is hiding.

Conclusion

I know the 500 error is annoying. And I too have been sitting in front of an (almost) white screen for hours. The good news is that 99% of the time your work isn’t gone! All your page content is in your database. The only problem is that we need to regain access to it.

And an “old hat” at the end: Please make a backup of your website before every update. In the worst case, you can always jump back to the last version! Keep an eye not only on WordPress updates, but also on your plugins and themes – as well as the technical performance of your hosting package.