How To Fix Internal Server Error On Your WordPress Site
If you got the internal server error and you are unable to access your WordPress site then,
Internal Server error is the common mistake you can face when something went wrong on your WordPress site while having a sweet journey with WordPress.
What is that something?
There is no straightforward answer to what causes the internal server error.There are lots of reasons that can cause WordPress to throw up this error like:
– .htaccess file got corrupted
– PHP memory limited got exceeded
– Improper file permission
– Broken plugins, and themes or
– It can be a problem from your hosting company as well.
So, no matter what causes the problem, there are different ways to solve the problem and take our site live back.
In this blog post, I am going to share the tips to troubleshoot the WordPress internal server error and will show you how to fix your site with this type of error.
If you have faced the WordPress internal server error issue and are looking for a solution, then just follow this step by step guide and work your way down the list until you identify the issue, resolve it, and make your site back in business.
Check For The Corrupt .htaccess File:
Starting the solution with the .htaccess file is good. The .htaccess file is usually a hidden file located in the folder where you have installed your WordPress. In case if the file is hidden then, you have to make it visible from the Cpanel Settings to do the necessary changes. This file contains rules that tell the server like what to do in certain circumstances. It is commonly used for rewriting URLs or preventing access to your site for malicious intent.
So to tackle down the problem, first rename the .htaccess file with any other name like .htaccess-old or something else and then open your site in the browser and check if it solves your problem.
If not then, we have to start to narrow down the problem by leaving the .htaccess file as it is and make a copy of the .htaccess file with some other name like .htaccess-old to have a backup.
Then open the file the .htaccess original file, i.e., the one with the name .htaccess in the text editor. Start removing blocks of code. Open your WordPress site in a browser tab and refresh every time while removing a chunk of code and see if it could solve your problem.
If at some point while removing a particular block of code, your site start working then in that case you have to copy all blocks of the code from the backup copy .htaccess-old file and leaving the chunk of the code that causes the problem.
If the internal server error still exists even after deleting everything from the .htaccess file, then the problem is not due to the .htaccess file, restore the original code again from the .htaccess-old file, and we have to move to the next step to fix our problem.
Increasing The PHP Memory Limit:
Sometimes a bad code, faulty plugin or broken theme overeat memory and cause exhausting your PHP memory limit. In such cases, you can face internal server error.
To increase the PHP memory limit, we have to look at the two scenarios.
If you see the internal server error only when you try to login to your WordPress admin. Then, first locate the file php.ini in the wp-admin folder. And if the php.ini file is there then, increase the memory to 64MB or 128MB by finding the line “memory=XMB” where “X‘ is the amount of memory already assigned. If the above line of code is not there then paste the line “memory=64MB” in the file.
If the php.ini file is not there, then you have to create an empty file and name it php.ini. After creating the file, paste the line of code “memory=64MB” and save the file.
Open your WordPress site in the browser and check if you can access your WordPress admin.
If the problem is not limited to only WordPress admin then you have to locate the file wp-config.php file in the WordPress site root directory and add the below line of code:
Save the file and open your site in the browser and check if it solves the problem.
In both the scenarios if you got your site back, then good you have done half of the work. Now You have to look into the server logs to find the accurate diagnostics.
If in both the scenarios the problem still exists then, go down the next step to fix the issue.
Remove Any Bad Plugin or Broken Theme:
Some Time internal server error in WordPress is caused by faulty plugin, broken theme or incompatibility among the plugins.
So, here also, we have to look at two scenarios.
If it is possible to access the WordPress admin, then go to the WordPress Dashboard and deactivate all the themes from the Themes section leaving the default WordPress theme only.
Open your site in a browser and check if the problem is solved then you are done.
If not Then deactivate all the plugins in the Plugins section and check your WordPress site in the browser if it solves the problem.
If the problem is fixed, then activate the plugins one by one, and hence you will find the one that was creating the problem.
If by removing the bad plugin or theme bring your site live back then it’s fine, and you did the job.
In case if we cant access WordPress admin, then go to your CPanel. And then go to the WordPress installation folder and find the wp-content folder. Then go to the WordPress default themes folder and move all the themes except default one outside the themes folder and put it into a folder by creating the new folder with any name.
After doing so, check your site in the browser and see if it could solve the problem. If not then move back all the themes to the WordPress default themes folder again and delete the newly created folder because the problem is not due to a broken theme.
If removing the themes didn’t solve the problem then find the plugins folder in the wp-content folder and rename it something else like plugin-old etc. Check your site in the browser. If the site starts working, then it was a problem due to a bad plugin, or maybe two plugins were not compatible with each other.
So now name the folder again with the same plugins name and start the process to rename all the plugins folder inside the WordPress default plugins folder with a trailing Underscore “_” to remember easily.
Then start removing the trailing underscore one by one from each plugin and check your site every time if the problem is fixed or not.
If the problem is fixed by renaming and naming back the different plugins to their original names, then you will find the plugin or plugins that are causing the problem, and you are all done.
If the internal server error issue still exits, even after checking for faulty plugins and themes then you have to move to the next step because the problem is not due to broken theme or plugin.
Reupload The WordPress Core Files:
If the above solutions did not fix your issue, then it’s time to take the next action.
Just download a fresh copy of WordPress from the WordPress official site and go to your Cpanel and open the WordPress installation folder.
After downloading WordPress, Copy the wp-admin and wp-includes folder from the freshly downloaded copy of the WordPress and upload it to the WordPress installation directory and replacing the existing folders.
Doing so will neither break anything, nor you will lose any of your information. But only the problem will be fixed if the problem is due to any corrupt file in the wp-admin or wp-includes folder.
If after checking the site in the browser, the problem is solved then, congrats you have fixed the issue. Otherwise, we have the last option.
Contact Your Hosting Service Provider:
If the problem was not fixed by following all the above steps. Then it’s time to contact your hosting provider. The issue could be a genuine server problem, which they can confirm from their server logs, and they can also look at things like file permissions and other sources.
Hope that the above possible solutions might fix your WordPress internal server error issue. If you have fixed the issue, then share with others so that others might also get benefit from it and fix their problem.
If you have fixed the internal server error problem by some other way, then do share your experience with us and let us know through your comments.