How To Fix A “There Has Been a Critical Error On Your Website” Error

Intro:

Also known as The White Screen of Death, this error is often displayed when there is a problem with loading a website. This critical error reduces the site’s functionality and can potentially affect the amount of traffic coming to your web.

There are multiple factors that contribute to this error. The best practice is to get to the bottom of the problem first and then take the necessary steps to solve it. So without further ado, let’s dive into the details of what might cause this error on your web.

Causes:

PHP Memory Limit:

It is the maximum storage a PHP script can use. Although the default is 128MB, it may not be enough for some webs, and therefore can cause this error to appear. Also, a high possibility exists that there might be a problem with your PHP code itself. This can be due to syntax errors or wrong configuration settings in the code.

To fix this, you need to install a larger memory limit for your PHP code. This can be done by contacting your hosting platform and asking them to increase the limit. Or if it’s possible, you can change the limit yourself by editing your php.ini file. For example; memory_limit = 128M  # Set to 128 megabytes

Plugin Conflicts:

A critical error such as this is often caused by faulty plugins.

It can happen when:

  • Your web is incompatible with the plugins that you use.
  • Existing plugins updates bring in new bugs and viruses into your web code.
  • You use plugins that can’t work simultaneously.
  • You use heavy and complex plugins that exhaust your server memory.

Now, to check if the plugins are the real problem or not, you have to first disable all the plugins on your website. If the problem is fixed, then activate each plugin one by one until your web shows the error again. When you find the imposter, delete it from your web ASAP!

The next step is to restore your website and find an alternative to that plugin. This is to make sure you don’t downgrade your web because of some faulty plugins. Lastly, monitor your web’s performance for a week or two to make sure everything is up to the mark.

Custom Theme Errors:

Themes might be another reason why your website gets stuck while loading. When you customise or update new themes, they might introduce new bugs into the system. Also, conflicts between custom codes and WordPress core files can become a reason why your web is showing this error. 

In this case, if the problem is caused by the theme, WordPress sends an email to you. You can follow the instructions provided in the email to access the Recovery Mode.

If the error is still buzzing around, it’s best to switch your website back to its original or default theme. If the critical error is solved, this means you have found the problem. Then you can make appropriate customisations to your old theme that don’t affect your web in any way. Or you can simply switch to a new one!

Outdated Software:

Using outdated versions of WordPress can lead to a whole lot of problems on your website. Issues such as:

  • Security: Outdated software increases the risk of viruses and spyware as well as security breaches. This leads to unresolved bugs and increases your web’s vulnerability.
  • Features: As time passes, outdated features become incompatible with future versions. As modern practices and standards are not met, it causes your web to shut down eventually.
  • Memory: Running outdated software causes more memory usage and therefore, leaves you with a website that’s buffering all the time! This can also lead to memory leaks and insufficient code.

To resolve this, keep your plugins, themes and WordPress versions updated. Upgrade your memory storage with a good backup system and test it across multiple devices to make sure everything is running smoothly.

Website Cache:

Although caching helps provide a smooth and swift experience for your users, it may sometimes be the root of your problem that needs to be cleaned ASAP!

At times, your site cache gets infected, or there are e a series of similar caches that exist simultaneously. This can lead to cache collisions and therefore become the reason for critical errors to show up.

To solve this problem, you should clear all your cache data from your website. Your cache files will be restored in no time, so don’t worry about it. This will clear out any files stuck in the system and your website will become operational. 

Malware Infection:

Malware includes everything from spyware in your web network that may steal all the confidential data to viruses and worms that replicate and make your servers go cray-cray. This makes your web unsafe and vulnerable to hackers and thieves.

Fighting malware is complicated – especially when you can’t even open your own website. It can modify itself into any form; PHP scripts, plugin/theme codes and even WordPress core files. It’s simply hiding in plain sight.

If you can’t recognize it, the best practice is to contact your web host or WordPress Support. Or leave it to the developers, as they have more experience and can detect malware from any code.

How to fix the “There has been a critical error on your website” error?

You’re here to get your site up and running again, and to that end, we’ve collected several different potential ways to fix the issue. Knowing that the cause is likely PHP-related, these may involve editing core WordPress files. Even with your site in a broken state, make sure to back it up before implementing any of these suggestions, as we don’t want to make it worse!

If you’re able to log in to your website’s backend, that will help immensely. But as your entire site is likely down, you very likely need to access it through FTP (or SFTP).

Contact your web host or look through your hosting dashboard to find your FTP login credentials, and make sure to install an FTP client like FileZilla. This guide on connecting to WordPress over FTP can help too.

  • Enable debug in WordPress
  • Roll back your site
  • Revert to a default theme
  • Disable all plugins
  • Raise the PHP memory limit
  • Increase the max upload file size and text processing functions
  • Clear your site cache
  • Upgrade your PHP version
  • Check for malware
Enable debug in WordPress

If you’re having trouble with WordPress, one of the first things you should do is enable debugging mode. This allows you to view any PHP errors on your site, helping you trace and identify the root cause of the problem.

As you may be unable to access your dashboard, you also need to enable the debug log. This will write all PHP errors to a file.

If you’re hosting with Kinsta, enabling debugging with MyKinsta is very easy. Log in to the hosting dashboard, then go to Sites > Tools > WordPress debugging and click Enable. You can then look around your site to find the cause of the issue or check the log. Make sure to disable debugging when you’re done, as it’s visible to your visitors as well as you.

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:

Here’s what it will look like when done:

wp-config.php debug

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. Even if you aren’t sure what to do with this information, save it someplace — it can help you if you need to reach out for support.

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

Roll back your site

When WordPress errors rear their head, restoring a backup can be a quick and easy way out. While it won’t always solve the issue, it’s definitely worth a shot. And if the problem happens again, you may be able to retrace your steps next time.

How you restore your website all depends on how you backed it up. If you use a plugin, follow the instructions in the documentation. If backups are included with your web host, you should do it from your hosting dashboard.

For instance, Kinsta users can restore a backup by logging into MyKinsta, finding your site under Sites, going to the Backups tab, then clicking Restore to

Before restoring to your live site, try it on a staging site to ensure that the site is indeed functioning and you’re not overwriting your hard work.

Revert to a default theme

Sometimes the critical error can be traced back to a conflict within your theme. The best way to test for this is to temporarily delete it and revert to a default theme, which should immediately clear up the issue.

Make sure you back up your site first, as you need a way to get your theme files back once they’re gone. Simply reinstalling the theme may cause you to lose your custom styling.

If you have access to your dashboard, this is easy. Just go to Appearance > Themes, click on the theme to select it, and then click Delete in the lower right corner of the pop-up window.

If you don’t see the option, then try downloading and switching to a different theme. The safest bet is to try a default theme like Twenty Twenty-One.

Changing the WordPress theme to a default option like Twenty Twenty-One

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

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!

To disable your plugins from the dashboard, visit Plugins > Installed Plugins and tick the checkbox at the top of the list to select them all. Then click Bulk Actions > Deactivate, which should be enough to disable any conflicts and restore your site.

You can also click Delete instead to entirely remove their files, though you will need to reinstall them manually or restore a backup.

Deactivating installed plugins in WordPress.

You can then turn them on one by one by returning to Installed Plugins and activating each of them.

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 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.
Defining the memory limit in wp-config-php

You can also try 256M if this doesn’t fix the issue, but anything higher is definitely unnecessary unless specifically called for in plugin documentation. If the issue is with the memory limit, the plugin you’re using is almost certainly broken and needs to be disabled.

A side note: Some hosts may enforce an extremely low memory limit and won’t allow you to raise it. If this is the problem, your only option is to switch to a better host or delete the plugin causing the problem.

While Kinsta does enforce a memory limit, it’s set to 256 MB. You should have no issues with legitimate working plugins on a Kinsta plan.

Increase 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. You can find this by visiting Media > Add New and checking beneath the file uploader.

Checking the maximum upload file size in WordPress

To fix either of these issues, you 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:

And to fix the breaking of large pages on your site, add this code:

Summary

The WordPress critical error can have a variety of causes, though the issue often has to do with PHP. Either the PHP memory limit has been exceeded, or your plugins or themes are having issues.

If you’re facing such problems that seem impossible to deal with, a developer is the best chance you have at solving the error. With over 6 years of experience and 1000+ fixed websites, I will help you through any problem. Whether it’s designing, back-end coding or debugging, I’ve got you! DM the details and we can get to it right away!

Hit me up on WhatsApp with your preferences and we’re good to go!