Fix WordPress There Has Been a Critical Error on This Website

The “there has been a critical error on this website” is undoubtedly one of the common errors that WordPress users might face. It prevents users from accessing the website, and in some cases, you can’t even access the admin panel.

Fortunately, fixing this critical error is sometimes as simple as adding a small PHP code or deleting a faulty plugin.

This article will explain what “there has been a critical error on this website” means and how to debug it in WordPress. However, before we can proceed with the different ways of solving this issue, we must first understand what this database error means.

What Does “There Has Been a Critical Error on This Website” Mean?

If you are using WordPress for a while, you’ve probably heard about, and maybe even encountered, the White Screen of Death. This surprising bug would cause your whole website, and occasionally even your backend, to load as a blank white page.

Since WordPress 5.2, this blank screen has been replaced with the critical error and the message “There has been a critical error on this website. Please check your site admin email inbox for instructions.” There’s also a link to the WordPress debugging guide.

The “There Has Been a Critical Error on This Website” error

It will also send an email to your WordPress site’s admin email address with further information about the error and a link to your WordPress dashboard in recovery mode.

What Are the Most Common Causes of This Error?

So, what causes this? Here are a few common causes.

  • There is a problem with your PHP.
  • Memory limit exceeded.
  • There is an error in your core, plugin, or theme files.
  • You have a corrupted database.

Whatever the cause, the error message sent by WordPress to your email address will explain it in detail and make it easier for you to troubleshoot.

How to Fix the “There Has Been a Critical Error on This Website”?

To fix a critical WordPress error, you must first find the cause of the problem. The notification email from WordPress has further information about which files and the line of code caused the problem, but don’t worry if you didn’t receive it.

There are several ways to find and fix critical errors on your WordPress site.

1. Check Your Error Logs File

If you have not received any WordPress notice emails, the first thing you should do is check your WordPress Error log file. All errors or PHP error information is kept in this file.

To view your error logs, open the FTP client on your hosting account and browse to home/[username]/.logs/error_log_[domain].

In general, error logs contain four types of PHP errors: parse errors, fatal errors, warnings, and critical errors. And if you find any critical or fatal errors, you must fix them right away.

2. Enable Debug in WordPress

WordPress comes with a debugging tool that finds code errors in the themes, plugins, and core software.

To enable the WordPress to debug mode, head to the wp-config.php file in your public_html directory. Then look for the following lines: define( 'WP_DEBUG', false ); define( 'WP_DEBUG_DISPLAY', false ); define( 'WP_DEBUG_LOG', false ); define( 'SCRIPT_DEBUG', false );

The “false” values indicate that the WordPress debug mode is disabled. To enable it, replace “false” with “true” on all lines.

These four lines include PHP constants. When they are activated, they do the following:

  • WP_DEBUG – It triggers the debug mode in WordPress.
  • WP_DEBUG_DISPLAY – It shows you debug messages on the pages’ HTML.
  • WP_DEBUG_LOG – It saves error details in the debug.log file.
  • SCRIPT_DEBUG – It helps to run the dev versions of CSS and JavaScript files instead of the minified versions.

If those lines aren’t in the wp-config.php file, just add them to the script. Remember to enter the “true” value on each line.

Once enable the debug mode, refresh your site. You should now see the error message above “there has been a critical error on this website”.

WP Debug Message

Fix the error according to the notice, and your site should normally work again. Once the issue has been fixed, disable the debug mode by setting the values to “false”.

3. Revert to a Default Theme

Sometimes a conflict in your active theme file will cause the “there has been a critical error on this website” message. The best solution to deal with this is to just revert back to your default theme and check out if the issue has been solved or not.

Make a backup of your site first since you’ll need a way to retrieve your theme files back once they’re gone. Simply reinstalling the theme may result in the loss of your customized styling.

It’s simple if you have access to your dashboard. Simply navigate to Appearance » Themes, click on the theme to pick it, and then click Delete in the bottom right corner of the pop-up box.

Changing the WordPress Theme to Default Option

If you cannot access the admin panel or WordPress dashboard, use an FTP software such as File Zilla to get your website files on the server and head to the public_html folder » wp-content » themes. Search for your active theme folder and either rename it or completely delete it.

If your website loads perfectly without any problems, it means there was a problem with your previous theme. You may now either reinstall your previous theme or give the folder its original name in order to return to it.

Check out: How to Uninstall and Delete WordPress Theme.

4. Disable All Plugins

A plugin is often to blame when you face a critical error. If you have several plugins on your site, finding the one that is causing the problem might be difficult.

However, there is an easy way to find the faulty plugin: simply turn them all off and see whether it solves the problem. If yes, enable them one by one until your site crashes again. And there’s the culprit!

To disable your plugins from the dashboard, go to Plugins » Installed Plugins and check the checkbox at the top to select them all. Then choose Bulk Actions » Deactivate, which should be sufficient to fix any issues and restore your site.

Disabling all WordPress plugins

You can then enable them one at a time by returning to Installed Plugins and clicking Activate on each.

If you are unable to get access to the WordPress dashboard, use an FTP software such as File Zilla to get access your website files and browse to the public_html folder » wp-content » plugins.

Similarly to how you did with themes, rename all of the plugin directories and check to see whether your website is working properly.

If your website loads properly, this indicates that the plugin was the primary cause of the issue. To identify which plugin is causing the problem, install each plugin one at a time while reloading the webpage.

If you deactivate the plugins manually by renaming the plugin directories, you must repeat the step to restore them by renaming all of the plugin directories to their original or previous names.

Check out essential WordPress plugins for new websites.

5. Increase Your PHP Memory Limit

Apart from the Theme or Plugin, the most common cause of “there has been a critical error on this website” is a lack of PHP Memory.

PHP memory limit refers to the fixed RAM memory on your web server, which is set by WordPress to allow PHP scripts to run inside the numbers. When this PHP memory limit is exceeded, the result is the White screen of death or a critical error.

However, you cannot make your PHP memory limit too high because a large PHP script would cause your website to crawl. However, your website’s default PHP memory limit may be too low. Thus just increasing the limit will absolutely fix the critical error.

To do so, connect to your site through FTP and open wp-config.php.

Now paste the following code snippet before the final line of code, then save it.

define('WP_MEMORY_LIMIT', '256M');

If it works, it means that whatever plugin you installed and activated is corrupt or broken and should be uninstalled immediately.

6. Increase Your Upload Max File Size Limit

A little adjustment to a few PHP functions could be able to fix the critical issue if you’re only seeing it in particular instances and not on every page.

When you upload large files and receive an error notice, it is most likely because the maximum upload file size is too small. However, increasing the recursion and backtrack limits can help to fix certain large sites that are broken.

To resolve either of these issues, log into FTP and edit the wp-config.php file, inserting the new code right above the last comment line.

To increase the maximum upload file size, enter the following code:

ini_set('upload_max_size', '256M'); ini_set('post_max_size','256M');

And, to keep large pages from breaking on your site, add the following code:

ini_set('pcre.recursion_limit',20000000); ini_set('pcre.backtrack_limit',10000000);

7. Clear Your Site Cache

Caching is a terrific way to speed up your website, and it’s usually a good thing. However, the cache might get corrupted, resulting in issues on your site.

When this happens, a simple option is to clear the cache, which should be enough to solve the problem and restore your site to a functioning order.

The cached version of your pages will be restored shortly, allowing your site to load rapidly again. Clearing the cache will simply remove the corrupted files that have become stuck.

Check out the best WordPress cache plugins to speed up your website.

8. Upgrade Your PHP Version

Outdated PHP can cause your site to crash, and more issues are almost certain to arise. You should normally run your site on the most recent version of PHP supported by WordPress, which is presently PHP 7.3 through 8.0.

Some WordPress users want to stick to PHP 7.4 because they are worried about theme and plugin compatibility. Normally, this will not create any issues. However, if you’re running PHP 5.x, you must upgrade immediately because it might cause major issues.

A PHP upgrade is a huge thing, so build a backup before proceeding.

9. Check for Malware

Malware can sometimes cause major errors, especially if you see strange PHP scripts that aren’t related to your plugins or theme. It’s tough to remove malware when you’re locked off of your website and can’t even run a scan.

It’s impossible to distinguish between legal files and those inserted by malware. Therefore removing arbitrary core files won’t help. Malware may also modify PHP files, hiding dangerous scripts that aren’t accessible unless you’re a developer.

In this case, the best thing you can do is either restore your website from a backup or contact your web host for assistance.

10. Restore Your Site to Backup

Restoring your site back to the last backup might be a simple and quick way to clear the WordPress errors. This tip is not certain to solve the problem, but it is worth a go. If the problem occurs again, it may be easier to identify the cause.

Restoring your website is dependent on your backup process. If you use a WordPress backup plugin, follow the documentation. If your web host provider offers backups, you may restore them from your hosting dashboard.

Conclusion

If you see the message “There has been a critical error on this website,” don’t panic.

Simply look for a message from WordPress in your inbox to identify and quickly solve the issue.

Even if you don’t receive the email, try the above methods to fix the issue.

WordPress critical errors can occur for various causes, the most common of which is PHP. Either the PHP memory limit has been reached, or plugins or themes are not operating correctly.

If you have a backup, rolling back your website is the easiest option, but you can also increase the PHP memory limit or identify and delete a faulty plugin as an option.

We hope this article has helped you fix the WordPress “There has been a critical error on this website” error.

You may also want to see our following articles:

Lastly, follow us on Twitter for regular updates on new articles.