WordPress may sometimes show you a message that ‘There has been a critical error on your website. With this message, WordPress is basically telling you that there is a fatal error on your website. During this period, the site will remain inaccessible to visitors, and you may be blocked from accessing the admin panel.

What is Critical Error in WordPress?

The critical error in WordPress is an error that stops WordPress from loading all the scripts it needs to work properly.

What Causes the Critical Error in WordPress?

The critical error in WordPress can usually be traced back to an issue with PHP: either your memory limit being surpassed, or an error in your code, plugins, or theme. It may also be an issue of database corruption.

All top WordPress plugins are thoroughly tested, so they are less likely to cause a critical error on their own. However, a conflict with another WordPress plugin or some custom code may trigger the error.

Fixing The Critical Error in WordPress

Below are methods of resolving critical errors in your WordPress site.

Enable Debug in WordPress

If you’re having trouble with WordPress, one of the first things you should do is enable debugging. With debug mode on, you’ll be able to see the various PHP errors occurring on your site, and you can use this to trace back to the root of the issue.

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.
  • Step 3: Place the following code at the bottom of the document or edit the code if it is already there, just before the final message, then save and close the file:

Here’s what it will look like when done:

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

define( ‘WP_DEBUG_LOG’, true );

Debugging is now enabled on your site and errors will be written to the log. You can find the debug log in the wp-content folder, named debug.log.

Look for names of your theme or plugins which will point to them being the cause or references to a specific file.

When you’re finished debugging, make sure to revert these lines of code.

Deactivate Your Site Plugins

When you’re having a critical error, a plugin is often to blame. If you have several or even dozens of plugins on your site, trying to locate the one that’s the issue may seem like a daunting task.

But there’s an easy way to find the problem plugin: simply turn them all off and see if that fixes the problem. If it does, enable them one by one until your site breaks again. And there’s the culprit!

You can deactivate a plugin from the Plugins area in your WordPress admin panel. But, in a situation where you’re blocked from accessing the back-end, you’ll have to deactivate the plugins manually.

You can find all the plugins used in your site by navigating to wp-content > plugins from your WordPress site’s root directory.

Restore Your Website From the Most Recent Backup Copy

The mere possibility of your WordPress site suffering a critical error is a good enough reason for you to regularly back up your site. Restoring a recent backup may be all you need to do to get your website working again in the shortest time possible.

The process of restoring a backup depends on how the backup was made.

Clear Your Site Cache

Caching helps your website to load faster by temporarily storing important and frequently used data. However, as data accumulates, it’s possible for the cache to get corrupted. When this happens, you’ll get a critical error on your site.

This problem can be resolved by clearing the cache. All the stale data will be deleted, and your site should start working again.

Raise the Max Upload File Size and Text Processing Functions

If you’re only seeing the critical error in certain situations and not constantly on every page, a small tweak to a few PHP functions might be able to fix it.

Uploading large files and finding yourself on an error screen is probably a result of the max upload file size being too small, while certain large pages breaking can be fixed by increasing recursion and backtrack limits.

First, check what your maximum upload size is and compare it to the file you’re trying to upload.

To increase the limit, open the wp-config.php file with a text editor and set the new maximum upload size in ini_set() as shown below:

ini_set(‘upload_max_size’ , ‘256M’ );

ini_set(‘post_max_size’,’256M’);

On the line above, we also increase the maximum size for text processing.

Upgrade Your PHP Version

Using an old version of PHP is a common cause of critical errors in a WordPress site. For this reason, you should always use the latest stable version of PHP for your WordPress site.

Stable versions are not prone to errors like the older versions (PHP 5.x). You also don’t have to worry much about plugin and theme compatibilities. If you’re on an old PHP version, upgrade it to PHP 7.4 or higher. But before you do that, make sure you have backed up your website.

Summary

The WordPress critical error is one of the most common errors in WordPress, and fortunately, it’s very easy to resolve. In this article, we looked at several ways to troubleshoot this error and bring your website back to life.

To briefly recap, they are as follows:

  • Enable Debug in WordPress
  • Deactivate Your Site Plugins
  • Restore Your Website From the Most Recent Backup Copy
  • Clear Your Site Cache
  • Raise the Max Upload File Size and Text Processing Functions
  • Upgrade Your PHP Version