There’s nothing scarier than having your WordPress website crash, especially if you receive a warning that reads, “There has been a critical error on this website.”
You must immediately learn how to resolve the major error if you find yourself locked out and the frontend completely unavailable. A conspicuous error screen is driving away visitors every minute that goes by.
Fortunately, resolving this serious issue typically only requires adding a little PHP function or removing a problematic plugin. Here, we’ll go over several methods for troubleshooting this problem and quickly restoring your website to functionality.
What Causes the “There Has Been a Critical Error on Your Website” Error?
If you’ve been using WordPress for any length of time, you’ve probably heard about—or perhaps even experienced—the White Screen of Death, which is one of the most notorious errors. Your entire website, and occasionally even your backend, would load as a blank white page due to this shocking bug.
The critical error and the words “There has been a critical error on your website” have taken the place of this blank screen in more current versions of WordPress. For instructions, please check the email inbox of the site administrator.
Though it may not be as frightening as your website completely failing to load, the error message isn’t any more informative than it was previously, and you’ll probably find yourself wondering: What’s causing this serious error?
Similar to the White Screen of Death, the problem is typically related to a PHP problem. This could be a memory overflow or a mistake in your theme, plugins, or code. Another possibility is database corruption.
Even while the error text may not be very helpful on its own, being aware of this facilitates debugging.
You may also want to look into these other WordPress errors, as you could be experiencing multiple of them:
- ERR_CONNECTION_TIMED_OUT — Caused by a slow or overloaded web server.
- ERR_CACHE_MISS — If you see this, look into your website’s cache or PHP tools like plugins, as they’re very likely the cause.
- 500 Internal Server Error — A serious error that can usually be traced back to server file corruption.
- Error Establishing a Database Connection — Corruption in your database or a database server issue can be the root of this problem.
- HTTP 503 Service Unavailable — Indicates an issue with your server.
- HTTP 502 Bad Gateway — Yet another server issue, often caused by too many visitors overloading it.
And if you see any other strange errors, look through these HTTP status codes.
How to Fix the “There Has Been a Critical Error on Your Website” Error?
We’ve gathered a few possible solutions because we know that your goal is to restore your website’s functionality. Considering that PHP is most likely the reason, this can entail making changes to core WordPress files. Before following any of these recommendations, even if your website is currently damaged, be sure to backup your site—we don’t want to make things worse!
It will be really beneficial if you can access the backend of your website. However, since your entire website is probably unavailable, you’ll probably have to use FTP (or SFTP) to access it.
To obtain your FTP login information, get in touch with your web host or check your hosting dashboard. Don’t forget to install an FTP client, such as FileZilla.
Enable Debug in WordPress
One of the first things you should do if you’re experiencing issues with WordPress is to activate debugging. You can use debug mode to observe the different PHP issues that are happening on your website and identify the source of the problem.
You’ll also need to activate the debug log because you might not be able to access your dashboard. This will create a file containing all PHP errors.
If you need to manually turn on debugging, or you need to access the debug log, follow these steps.
- Step 1: Connect to your site with FTP.
- Step 2: Find wp-config.php in the root folder and open it with a text editor or IDE.
- Step 3: Place the following code at the bottom of the document, just before the final message, then save and close the file:
define( 'WP_DEBUG', true );
define( ‘WP_DEBUG_DISPLAY’, false );
define( ‘WP_DEBUG_LOG’, true );
Your website is now enabled for debugging, and failures will be logged in the log. The debug log, called debug.log, is located in the wp-content folder.
Look for references to a certain file or the names of your theme or plugins that will indicate that they are the source. Save this information somewhere, even if you’re not sure what to do with it. You never know when you might need to ask for help.
As soon as you have completed debugging, make sure to delete these code segments.
Roll Back Your Site
Restoring a backup might be a quick and simple fix for WordPress issues. Even though it won’t work every time, it’s still worth a try. In addition, you might be able to go back and follow your original path if the issue reappears.
The method you used to backup your website will determine how to restore it. Observe the documentation’s guidelines if you’re using a plugin. You should be able to do backups from your hosting dashboard if they are part of your web hosting package.
Revert to a Default Theme
Sometimes a dispute inside your theme is the source of the critical error. The best method to test for this is to remove it briefly and go back to the normal theme; this should resolve the issue right away.
As you’ll need a mechanism to recover your theme files in the event that they disappear, make sure you back up your website first. Reinstalling the theme might not be enough to save your personalized styling.
This is simple if you can access your dashboard. Simply navigate to Appearance > Themes, click the theme to make it selected, and then click Delete in the pop-up window’s lower right corner.
Try downloading a new theme and switching to it if you can’t see the option. Using a default theme, such as Twenty Twenty-One, is your best chance.
If you don’t have access to your backend, follow these instructions to revert to a default theme with FTP.
- Step 1: Connect to your site with FTP.
- Step 2: Navigate to wp-content/themes. You have two choices here: either rename your theme folder (will allow you to turn the theme back on later) or simply delete it.
- Step 3: If you don’t have a backup theme here already, manually download Twenty Twenty and place its files into the themes folder.
Your site should now revert to Twenty Twenty. If it loads properly now, you know it was a theme conflict.
To restore your theme files, simply reinstall the theme or change the folder back to its original name.
Disable All Plugins
A plugin is frequently to fault when you’re experiencing a critical problem. It may seem impossible to find the problematic plugin when your website has dozens or even hundreds of them.
However, there’s a simple way to identify the problematic plugin: just disable them all and check if the issue is resolved. If so, enable each one individually until your website crashes once again. And there is the offender!
Go to Plugins > Installed Plugins on the dashboard, select all of your plugins by checking the box at the top of the screen, and then disable them all. After that, all you need to do is click Bulk Actions > Deactivate to disable any conflicts and restore your website.
You can also click Delete instead to entirely remove their files, though you will need to reinstall them manually or restore a backup.
You can then turn them on one by one by returning to Installed Plugins and clicking Activate on each.
You can do essentially the same thing through FTP.
- Step 1: Log in to your site with FTP.
- Step 2: Open the wp-content folder to find your plugins.
- Step 3: Rename the plugins folder to plugins_old and verify that your site is working again.
- Step 4: Rename the folder back to “plugins”. The plugins should be disabled still, so you should be able to log in to your dashboard and activate them one by one. If the plugins reactivate automatically, rename individual plugin folders with _old until your site is restored.
Raise the PHP Memory Limit
Even if a plugin or theme is the cause of your broken website, the PHP memory limit is often the real one to blame.
What is the PHP memory limit? Your web server only has a certain amount of RAM, or memory, so WordPress sets a hard limit on how much memory a single PHP script can take up. When this limit is exceeded, you’ll encounter the white screen of death or the critical error.
While you don’t want to set the memory limit too high and allow misconfigured scripts to slow your site to a crawl, the default value may be far too low. Raising your PHP limit just a bit could instantly fix your broken website.
- Step 1: Access your site through FTP and open wp-config.php.
- Step 2: Insert the following code right before the final line and save.
define( 'WP_MEMORY_LIMIT', '128M' );
If 256M doesn’t resolve the problem, you can also try that, but anything greater isn’t really essential unless the plugin documentation calls for it. It’s most likely that the plugin you’re using is defective and needs to be disabled if the memory limit is the problem.
As an aside, certain hosts could impose a very low RAM restriction and prevent you from increasing it. Your only choices, if this is the issue, are to move to a better host or uninstall the problematic plugin.
Raise the Max Upload File Size and Text Processing Functions
If the critical error is occurring just occasionally and not on every page, you may be able to resolve it with a little adjustment to a few PHP functions.
The maximum upload file size being too small is likely the cause of huge file uploads that result in an error screen; however, increasing the recursion and backtrack limits can resolve some large page breaks.
Check your upload limit first, then make sure the file you’re trying to upload fits within it. By going to Media > Add New and looking under the file uploader, you can locate this.
To fix either of these issues, you’ll need to log into FTP and edit the wp-config.php file, placing the new code right above the final comment line.
To increase the max upload file size, add this code:
ini_set('upload_max_size' , '256M' );
ini_set('post_max_size','256M');
And to fix the breaking of large pages on your site, add this code:
ini_set('pcre.recursion_limit',20000000);
ini_set('pcre.backtrack_limit',10000000);
Clear Your Site Cache
Caching is generally a positive thing and is a wonderful technique to speed up your website. However, occasionally the cache may get tainted, causing issues on your website.
When this occurs, clearing the cache is a quick fix that should take care of the issue and get your website back up and running.
You can relax knowing that your site will load swiftly again because the cached version of your pages will be restored shortly. The corrupted files that are stuck can be removed by simply clearing the cache.
Upgrade Your PHP Version
PHP versions that are too old can crash your website and lead to other issues. Generally, you want your website to run on the most recent PHP version that WordPress supports, which is PHP 7.3 to 8.0 at the moment.
Some WordPress users are worried about theme and plugin compatibility, thus they would rather stick with PHP 7.4. This usually won’t lead to any issues. However, you must upgrade if you’re still using PHP 5.x because it may result in major issues.
Before doing a PHP upgrade, ensure sure you have a backup available.
Check for Malware
Malware can occasionally be the cause of a major error, particularly if you’re seeing weird PHP scripts that you can’t associate with your theme or plugins. It’s difficult to remove malware, especially if you can’t even perform a check since you’re locked out of your website.
It can be challenging to distinguish between files added by malware that are suspect and those that are valid, and erasing random core files is probably not a good idea. Malware can also change PHP files, inserting dangerous scripts that, unless you’re a developer, you won’t be able to identify.
It may be preferable to contact your web host for assistance if you believe malware is the root of the problem.
Summary
There are numerous reasons why WordPress critical errors occur, however PHP is frequently the cause of the problem. Either your plugins or themes aren’t working properly, or the PHP memory limit has been hit.
If you have a backup of your website, going back to that version is the fastest approach to fix the issue. Other solutions include increasing the PHP memory limit and locating and deleting a problematic plugin.
Try a few different things while troubleshooting if necessary, but don’t give up if you can’t resolve the issue on your own.