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

Nothing is more terrifying than when your WordPress site goes down, especially when you get an alarming message like “There has been a critical error on this website.”

When you’re locked out and the frontend is entirely down, you need to know how to fix the critical error now. Every minute that passes is driving away visitors as they encounter a glaring error screen.

Luckily, fixing this critical error is usually just a matter of adding a small PHP function or deleting a problem plugin. Let’s go over a variety of ways to troubleshoot this issue and get your site up and running again fast.

What causes the “There has been a critical error on your website” error?

If you’ve been using WordPress for some time, you’ve likely heard of or possibly even encountered its most infamous error: the white screen of death. This startling glitch would cause your entire website, and sometimes even your backend, to load as a blank white page.

In recent versions of WordPress, this blank screen has been replaced with the critical error and the text “There has been a critical error on your website.

While this is less panic-inducing than your site simply refusing to load at all, the error text isn’t much more helpful than before, and it’s likely to leave you wondering: What causes this critical error?

Much like the white screen of death, the issue 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.

While the error text itself may not be very helpful, knowing this makes troubleshooting much easier.

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?

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 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 );

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, WeWP users can restore a backup by logging into MyWeWP, 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 backup 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.

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.

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.

  • define( 'WP_MEMORY_LIMIT', '128M' );

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 WeWP does enforce a memory limit, it’s set to 256 MB. You should have no issues with legitimate working plugins on a WeWP 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.

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:

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 a great way to speed up your website, and most of the time it’s strictly a good thing. But sometimes the cache can get corrupted, leaving your site throwing out errors.

When this happens, a simple solution is to clear the cache, which should be all you need to get rid of the problem and restore your site to working order.

No fear: The cached version of your pages will soon be restored, allowing your site to load quickly again. Clearing the cache will simply delete the stuck corrupted files.

MyWeWP users can clear their site’s cache through their hosting dashboard. Visit Sites > Tools and then click Clear Cache.

Using a different host, or maybe a caching plugin? Check out their documentation; they should be able to give you detailed instructions.

Upgrade your PHP version

Outdated PHP can cause your site to break, and other conflicts are sure to occur. You usually want your site on the latest version of PHP supported by WordPress, which is currently PHP 8.1, 8.2 and 8.3.

Some WordPress users prefer to stay on a lower PHP version as they’re concerned about theme and plugin compatibility. Usually, this won’t cause problems. But if you’re using a lower PHP version, it’s imperative you upgrade as it can cause serious conflicts.

A PHP upgrade is a big deal, so make sure you have a backup ready before trying it.

WeWP users can upgrade PHP version with WeWP without needing to do anything complicated. Just log in and go to Dashboard, then click Modify under PHP engine. Select the version you want and, after a short wait, your site will be running on the latest PHP version.

If you’re not using WeWP, upgrading PHP will rely on your host. Contact them for help.

Check for malware

Sometimes a critical error can be caused by malware, especially if you’re noticing strange PHP scripts that can’t be traced back to your plugins or theme. Removing malware is a tough task, more so when you’re locked out of your website and can’t even run a scan.

It can be hard to tell the difference between legitimate files and suspicious ones added by malware, and deleting random core files isn’t likely to end well. Malware can also modify PHP files, hiding scripts in them you won’t notice as malicious unless you’re a developer.

If you suspect malware is the cause, then it may be best to turn to your web host for help.

Conclusion:

Encountering the "There has been a critical error on your website" message can be alarming, but with the right approach, it's often fixable. This error, typically caused by PHP issues, can stem from various sources such as memory limits, faulty plugins or themes, or even malware.

Here are the key steps to troubleshoot and resolve the critical error:

  1. Enable Debugging: Turn on WordPress debugging to log PHP errors, which can help identify the issue.

  2. Roll Back Your Site: Restore a recent backup to revert your site to a working state.

  3. Revert to a Default Theme: Switch to a default WordPress theme to rule out theme-related issues.

  4. Disable All Plugins: Deactivate all plugins to check if one of them is causing the problem, then reactivate them one by one.

  5. Raise the PHP Memory Limit: Increase the PHP memory limit in your wp-config.php file to ensure scripts have enough memory to run.

  6. Increase Upload Size and Text Processing Limits: Adjust these limits in wp-config.php if large uploads or page loads are causing errors.

  7. Clear Your Site Cache: Remove corrupted cache files that might be causing the issue.

  8. Upgrade PHP Version: Ensure your site is running on a supported and up-to-date PHP version.

  9. Check for Malware: If suspicious files or scripts are found, seek assistance to remove potential malware.

Following these steps methodically can help you identify and fix the underlying cause of the critical error, restoring your site to full functionality. Always remember to back up your site before making any changes to prevent further complications. If the problem persists, reaching out to your web host or a professional may be necessary.

Last updated