Fixing “There Has Been a Critical Error on This Website” in WordPress
When your website displays the “White Screen of Death” with the dreaded message, “There has been a critical error on this website,” it may feel like your website has had it. Fortunately, all is not lost, and several options are available to fix it.
Keep reading as we’ve gathered the best methods to resolve this error and have your site back up and running in no time.
What Causes a Critical Error in WordPress?
A glitch causing your entire website and possibly the back end to display as a white page can be worrying. WordPress lets you know there is a problem with the following message: “There has been a critical error,” and to check the admin email for more instructions. In addition to slight panic, this message may leave you wondering what could cause this.
In general, critical errors in WordPress are triggered by the following:
- A problem with PHP
- An exceeded memory limit
- A broken plugin, theme, or code
- A plugin conflicting with another
- A corrupt database
Your site could be experiencing several errors. Understanding what they mean helps make troubleshooting easier.
- “HTTP 502 Bad Gateway:” A server problem caused by visitor overload.
- “HTTP 503 Service Unavailable:” A server problem.
- “500 Internal Server Error:” This is another critical error usually caused by server file corruption.
- “Error Establishing a Database Connection:” This problem can be caused by a corrupted database or database server.
- “ERR_CACHE_MISS:” Your website’s cache or PHP tools, like plugins, will likely cause this issue.
- “ERR_CONNECTION_TIMED_OUT:” The error could result from an overloaded or slow web server.
If you receive any other strange errors, you can check out the meaning using this guide to WordPress HTTP error codes.
How to Fix a WordPress Critical Error
Here are the most common troubleshooting tips to try to recover your website.
Activate Debug Mode in WordPress
One of the first things to do when solving a WordPress problem is to activate the debug feature. With debug mode enabled, you’ll see the different PHP errors happening on your site. This information can be used to find the root cause.
If you cannot access your dashboard, you’ll need to turn on the debug log to gather all the PHP errors. Follow these steps to access the debug log and enable debugging.
- Connect to your site using FTP.
- Look for the “wp-config-php” via the root folder and open it using IDE or text editor.
- Copy and paste the following code before the last message, then save and close the file.
define(‘WP_DEBUG’, true ); define(‘WP_DEBUG_DISPLAY’, false ); define(‘WP_DEBUG_LOG’, true );
All errors for your site will now be written to the “debug.log” file, found in the “wp-content” folder.
Go through the errors to find names of the plugins or themes installed or references to specific files indicating there is a problem.
Once you have finished going through the log, remove the lines of code from the “wp-config-php” file.
Restore Your Site to Backup
Rolling your site back to the last backup could be a quick and easy way to clear the WordPress errors. This tip is not 100% guaranteed to fix the problem, but it is worth trying. If the problem happens again, it may be easier to pinpoint the cause.
Restoring your website depends on your backup process. If you use a backup plugin, follow the documented instructions. If your web host provider includes backups, you can restore from your hosting dashboard.
Disable All Plugins
Plugins are typically to blame for a WordPress critical error. Finding the problematic one can be tricky if you have several plugins installed on your site. A quick way to discover whether a plugin is the issue is to disable all of them to see if the problem goes away. If it does, enable them one at a time until you find the one that breaks the site again.
Follow these steps to disable and then enable your plugins.
- Sign in to your WordPress dashboard.
- Select “Plugins” and “Installed Plugins.”
- Check the box at the top of the list to select all plugins.
- Click “Bulk Actions,” then “Deactivate.” This should resolve any conflicting plugins and restore your site.
You could also delete plugins to remove their associated files. However, you’ll need to reinstall them or restore a backup.
Select the Activate option beneath each plugin to enable it. After each one, check whether the critical error has returned. Once you find the culprit, delete it and find a substitute or search for information regarding compatibility issues with the plugin.
Revert to a Default Theme
A conflicting theme can also cause critical errors. Test to confirm whether this is the case by temporarily switching your theme to a default theme like “Twenty Nineteen,” “Twenty Twenty,” or “Twenty Twenty-one.” If the issue is with the theme, this should resolve it immediately.
Ensure you have a backup first so it will be easier to get all your theme files back. Reinstalling your theme may not include your customized styling.
Follow these steps to switch to a default theme.
- Sign in to your WordPress dashboard.
- Go to “Appearance,” then “Themes.”
- Click on a current theme to select it, then in the bottom-right corner of the pop-up, click “Delete.”
- If the option to delete the theme is unavailable, try downloading and then changing your theme to a WordPress default theme.
Increase the PHP Memory Limit
Even if a theme or plugin caused your website to break, a PHP memory limit is often the actual cause.
Your web server will have a specific amount of memory or RAM. WordPress limits the amount of memory a PHP script can use. The white screen and critical error message will display if this limit is exceeded.
Setting the memory limit too high will cause misconfigured scripts to slow down your site, yet the value could be too low. Increasing your PHP limit slightly could fix it instantly.
Follow these steps to raise your PHP limit.
- Access your website via FTP.
- Open the “wp-config.php” file.
- Copy and paste the following code before the final line, then save.
define(‘WP_MEMORY_LIMIT’, ‘128’ );
If this doesn’t clear the error, try a memory limit of “256M.” Anything higher than that is excessive unless explicitly requested in the plugin documentation.
Upgrade Your PHP Version
Older PHP versions can cause critical errors. Your site should be on the latest PHP version supported by WordPress.
Some WordPress users prefer to stay on older PHP versions for as long as possible due to plugin compatibility issues. If your website is using PHP 5.x, upgrading as soon as possible is essential as the conflicts can be severe. PHP upgrades are significant, so be sure to back up before upgrading.
All WordPress hosting companies allow you to upgrade the PHP version easily. Here’s how it’s done in Bluehost.
- Sign in to your Bluehost dashboard.
- Select the “Advanced” tab on the left.
- From the Advanced tools page, click the “MultiPHP Manager” icon.
- On the following page, click on the “PHP version” dropdown arrow to select the PHP version you want to upgrade.
- Click “Apply.”
Clear Your Website Cache
Although caching is the best way to speed up your website, sometimes the cache can become corrupted. Simply clearing the cache will delete stuck and corrupted files, then have your site running as expected. No need to worry about deleting your website cache since the cached version of your pages is restored, so your site can continue to load quickly.
Different hosting providers will use similar steps to clear the website cache via the dashboard. Bluehost makes it easy by providing the option in the WordPress admin area. The following steps can give you an idea of how it’s done.
- Sign in to your WordPress dashboard.
- Go to the “Caching” button from the toolbar at the top.
- Select “Purge All.”
Bluehost will immediately clear the files from your website’s cache.
Check for Malware
Malware can also cause critical errors on websites and could be the cause in this scenario if you notice weird PHP scripts that you can’t trace to a theme or plugin. If you’re locked out of your website, you won’t be able to run a scan. In addition, it can be hard to tell whether a file is legitimate or has been added by malware. Malware can also change PHP files, which you may overlook unless you’re a developer.
If you think malware could be the reason for the critical error, consider asking your web host for assistance.
Get Your Home Page Back
There is not much that’s more alarming than seeing a “There has been a critical error on this website” message instead of your lovely homepage when visiting your website. If your website makes you money, getting it back up fast is the priority. Although a critical error may seem like the end of the world, there are many ways it can be resolved.
A problematic theme or plugin is usually to blame, which is quickly resolved by disabling the plugin or temporarily changing a theme. An upgrade to the latest PHP version is also known to help. Be sure to back up your site before trying any fix so it’s easier to return to your customized settings if necessary.
Is your website working as expected now? If so, what did you do to clear the error? Tell us all about it in the comments section below.