500 Internal server error in WordPress - how to fix?
If you are working on WordPress for a quite long time you have probably seen 500 Internal Server Error. It's a common problem and there are many reasons why it appears. This error should be fixed as soon as possible if we are talking about live website. I want to show a few fixes for this problem.
First of all please make a backup of WordPress website. There is a chance that you don't have access to the dashboard and you will not be able to backup using this plugin.
In this case, you should copy all your WP files to hard drive and copy database using phpMyAdmin.
The reason of Internal Server Error can be corrupted .htacces file. You can check it by renaming file .htacess to for example .htacces_backup. This file is located in the main directory of your WP installation. If renaming this file would help you have a corrupted .htaccess file, and now you should go to Settings -> Permalinks and click Save Changes.
This action will create a new .htaccess file that should be correct.
PHP Memory Limit Error
Another issue could be too small memory limit in PHP settings. Usually, this is the reason when you see an error while uploading a file or sometimes when you try to login to the dashboard.
To fix PHP memory limit error try to create file php.ini or .user.ini (depending on your hosting) with this content:
memory_limit = 128M
Now copy this file to your main Wordpress directory.
Some hostings do not allow change memory limit in that way. You can then edit wp-config.php file located in the main WordPress directory. Add code:
right after first <?php mark.
If the problem is gone you have to take a look at your plugins or theme functions. They could overload PHP memory limit. We recommend contacting your hosting company. They should take a look at logs and diagnose the memory problem.
Plugin / theme bug or conflict
There is also a possibility of a bug in theme/plugin. It could also be a conflict with some already installed and activated plugin.
To find out which plugin causes a problem simply deactivate all plugins in a dashboard. Go to Plugins, select all plugins, choose action Deactivate and click Apply.
If you don't have access to a dashboard, you can also deactivate plugins using FTP. Go to wp-content directory and rename dir plugins to plugins_off.
If deactivating all plugins will help then you need to activate all plugins one by one until you get Internal Server Error again.
If you have deactivated all plugins using FTP method, please create directory plugins next plugins_off dir. Then move folders with plugins from plugins_off to plugins directory one by one. For example, if you have plugin My Plugin, move folder wp-content/plugins_off/my-plugin to wp-content/plugins.
Debug WordPress website
You can also debug your WP installation. To do that please edit wp-config.php file located in the main WP directory. Change code:
If you want to log errors to a file wp-content/debug.log add code:
Checking WordPress permissions
You can also check files and folders permissions in your WP installation. Files should have permissions 644 and folders - 755. Any other settings may cause problems, especially Internal Server Error.
Uploading Wordpress core files
If none of this methods are working, you can try to re-upload WP core files. Download WordPress and copy directories wp-admin and wp-includes from this ZIP file to your WP installation. Just override these files on your server. This action will not override your data, ex. posts, pages, etc.
As you can see this problem could have many reasons and fixing it is not a nice job. Remember about backup before any attempt to fix your website.
Please try above methods before contacting your hosting for checking your website server error log :-)