Have you just opened your WordPress site to suddenly find "There has been a critical error on your website. Learn more about debugging in WordPress." even though this might be terrifying, to say the least, your site isn't lost and there is hope left still!
We will be discussing the error in more detail and troubleshooting to fix the error message and prevent it from happening again in the future.
What does "There has been a critical error on your website." mean?
Somewhat similar to the blue screen of death with Windows (Yes, that annoying error *sigh*), well, WordPress has implemented their own version of this, which we refer to as the white screen of death. The thought alone is scary. The premise of waking up in the morning, making a fresh brew, starting the day by blogging to open your WordPress site, and low and behold "There has been a critical error". The critical error is usually caused by a faulty plugin or theme.
How to Fix the WordPress Error “There has been a critical error on your website” issue
The most obvious and straightforward solution is to restore your website to the previous working version. In order to do that, you need to make sure that your hosting does come with backups provided, but not everyone does.
Let's work from the premise that you don't have backups and you're probably wondering, what do I do? - Well, we're going to discuss the next steps of diagnosing the critical error.
Enabling WordPress Debugging
The most overlooked but simple diagnosis which in my experience of working with WordPress is enabling WordPress debugging. Enabling WordPress debugging will give us a more detailed error as to what could be triggering the critical error message.
To enable WordPress Debugging on your website follow these steps (For cPanel users)
1.) Manage your hosting through cPanel and go to 'File Manager'.
2.) Navigate to the public_html directory. This is where your WordPress installation will typically be, if you have set-up a custom directory path, then switch to the respective directory.
3.) Open/edit the wp-config.php file and looks for the following line 'define('WP_DEBUG', false)' by default this should be set to false. Update this so it reads the following instead 'define('WP_DEBUG', true)' and select save. If for whatever reason this line is not currently in your wp-config.php file, then feel free to add the snippet in.
If you have successfully followed the above steps then congratulations! You have enabled WordPress debugging on your site and we can now get a bit more information to work with.
OK, say the error we have now got is down to a plugin or theme you have active on your site. What are the next steps in fixing the problem?
We'll go over both theme and plugin troubleshooting and hopefully get you back up in running in no time!
Theme Conflict Troubleshooting
In order to disable the theme navigate to the following directory path (This may be different depending on your set-up) 'public_html/wp-content/themes/' - when you're in the aforementioned directory, you should see a list of current themes on your WordPress site. To disable one of the themes, you will need to rename the folder to include DISABLE at the end of the file name (Show in the example below)
Upon doing that, go back to your WordPress site and refresh, you should now no longer be seeing the critical error.
Plugin Conflict Troubleshooting
If it's not the theme, but a plugin issue. Just like the theme troubleshooting, this is similar. If we know the plugin in question we can simply rename the plugin to turn it off. In order to do this, navigate to the 'public_html/wp-content/plugins/' folder and re-name the plugin.
For example, if we know the critical error is caused by wordfence, we can rename this to wordfenceOLD. It's important to note that by disabling the plugin, you won't lose any of your previous settings.
The plugin should now be disabled! If you re-visit your site and refresh, hopefully, the error has gone.
We hope this blog post finds you well and offers a glimmer of hope in fixing your WordPress critical error. If for whatever reason none of the above has worked, you will need to contact your web host and their support team should be able to shed more light on the issue.