The Internal Server Error (500 status code) indicates that something is wrong with the setup of your website or the server your website resides on. This particular error is somewhat frustrating as it requires some troubleshooting and isn’t always straight-forward.
Before we start, make sure to create a backup of your WordPress files and database, as some of these steps make a lot of changes, so it’s good to be on the safe side.
Invalid .htaccess file
The most common issue when it comes to error 500 is .htaccess becoming corrupt. What you need to do in this case is rename the old .htaccess file to .htaccess_old, for example, via File Manager in your control panel.
Once completed, login to your WordPress dashboard and head to Settings > Permalinks and click the save button without changing anything. This process will tell WordPress to generate a new .htaccess file with the default structure and help avoid having any 404 errors due to missing rewrite rules.
PHP memory limit
It’s common for the Internal Server Error to occur when your website hits a predefined PHP memory limit on your hosting account.
Most often, the error will show when you try to login to your WordPress dashboard or if you try to upload an image to the media library.
Depending on the PHP setup, there are a couple of ways to increase the PHP memory limit.
1) Create an empty text file with php.ini name
2) Paste following code: memory=64MB
3) Save the file
4) Upload the file to /wp-admin/ folder via FTP or your File Manager
1) Login to your root website directory via FTP or File Manager
2) Locate the wp-config.php file and edit it
3) Paste the following code under the opening PHP tag:
define('WP_MEMORY_LIMIT', '64M');
4) Save the file
Refresh your website, and if this change fixes the problem – leave it in place. If not – remove the code and save the file again. If the problem is fixed – keep in mind that this is just a stop-gap solution, and you need to find the exact culprit as merely increasing the PHP memory limit isn’t feasible.
You can check our article here for tips on how to optimize your WordPress application and increase performance.
Deactivate your plugins
If none of the above solutions helped with the problem, the error might be caused by one of the plugins you use (or a combination of them). Unfortunately, there is no obvious way to find this out, so you need to deactivate all your plugins at once.
To disable all your plugins:
1) Login to your website via File Manager
2) Head to /wp-content/ directory
3) Rename plugins folder to plugins.old for example
If the problem is fixed – then you know it is one of your plugins causing the issue. The next step would be to reactivate all your plugins by renaming the folder back to plugins and then disable them one by one (by adding .old in plugin name) to see which specific one causes the issue.
Re-upload WordPress core files
If disabling your plugins didn’t help either, the next solution would be to re-upload WordPress core files (/wp-admin/ and /wp-includes/ folders) from a fresh WordPress installation.
Keep in mind that this won’t remove any information on your website, but it might help with the issue.
Head to WordPress website and click on the Download WordPress button.
This will download a ZIP file to your computer, which you need to extract. Once completed, login to your website via FTP and rewrite original /wp-admin/ and /wp-includes/ folders with the folders from the ZIP archive.
If your WordPress files were corrupted previously – this will solve the problem.