The “There Has Been a Critical Error on Your Website” in WordPress is a cryptic error that’s not very useful – and at the same time, it’s utterly paralyzing and frustrating because you can’t access the WordPress dashboard or deactivate plugins and themes that may be causing the critical error.
Here’s a screenshot of what the critical error looks like:
There aren’t any buttons or indications as to what went wrong to cause the critical error. As a result, you have no choice but to fix the problem from the backend, and for a newbie, it can be panic-inducing.
In this article, we’ll look at what causes the critical error, how to prevent the critical error on your website, and how to fix it and get your WordPress website back up and running as normal.
- Common Causes of The “There Has Been a Critical Error on Your Website” Error
- How to Access Your WordPress Files During the Critical Error
- Summary: Make Sure You Have Backend Access
Common Causes of The “There Has Been a Critical Error on Your Website” Error
Here are the main reasons why you may be running into this critical error on your WordPress site.
#1. A Coding Error in A WordPress Plugin
If you’ve recently changed a plugin on your WordPress site or it was recently updated if you have automatic updates enabled, there’s a good chance that it’s the cause of this critical error.
How To Prevent the Error A Coding Error In WordPress Plugins
I always wait for at least 4 days to keep my website safe before updating a plugin. Often, plugin updates come with bugs that can cause your site to break. These bugs are usually fixed once the community discovers them and the author releases a fix. But why be the guinea pig? Wait for four days after the initial update notification comes up for a particular plugin, just to be safe.
The second precaution is to always take backups before modifying the plugin code. Or at the very least, copy and paste the plugin code into a temporary location like Notepad so that you can paste everything back in case something goes wrong. This has saved my bacon multiple times when I made a syntax error while modifying my plugin.
Finally, on a related note, ensure that you take backups regularly. NameHero backups run on your site automatically, so you don’t need to worry since you can restore them easily without requesting a ticket. Many web hosts like NameHero also let you restore specific files and folders, so if you know which plugin is causing the problem, you can restore just that one.
Additionally, Never Use The Built-In WordPress Plugin Editor
WordPress has a handy feature that allows you to edit theme and plugin files using the File Editor within your WordPress dashboard. This enables you to edit source for your WordPress theme or plugins. Here’s what it looks like:
However, if you accidentally make a mistake, you can break your site and get this critical error message and you won’t be able to use the file editor to reverse the changes. WordPress has gotten a lot better in recent years, as it tries to reverse changes to the files if they generate an error and warns you that something has gone wrong. But it can still be dangerous, and WordPress throws a warning when you try and access the editor for the first time.
To be safe you should edit plugin and theme files only using a backed editor like the file editor in cPanel. You can also use SFTP to make file changes. This way, if your site breaks, you can reverse the changes and have your WordPress website back to normal immediately.
#2. Errors in Your WordPress Theme
This is another source of the “There Has Been A Critical Error On This Website” critical error message, which are coding mistakes in WordPress themes. While far rarer than plugin errors, due to the infrequency of theme updates, they can be far more devastating because it’s not easy to disable a theme without tanking your WordPress website.
So it’s even more important to wait a long time before updating a default theme you’re actively using on your WordPress website. And if you’re making manual changes to your theme, ensure that you have backups in place for the entire theme folder, not just the file you’re changing.
If you cannot edit a theme directly, use a child theme instead to further reduce the chances of updates breaking your site.
#3. Insufficient PHP Memory Limit
Another potential source for the “There Has Been A Critical Error On This Website” error is when your site’s requirements exceed the available PHP memory limit for the application. Sometimes, this is a hard limit that’s not in your control if you’re on a shared hosting plan since the web host can configure it that way. It also may be dictated by the PHP version that comes by default with your web server.
If you’re lucky, and this is the source of the error, you can fix the critical error with a quick change to your wp-config.php file.
This file is located at the root of your WordPress installation and part of the WordPress core files. Open it, and add the following line just before the following message:
That's all, stop editing! Happy blogging.
256 MB should be more than enough memory for your PHP application, so give it a whirl and see if it solves the problem. PHP errors like this one are also something you can bring up to a support staff member at NameHero and they may be able to pitch it in to fix the critical error.
#4. A Hacked Website
If you haven’t made any changes to either themes or plugins recently and haven’t updated either of these, it’s possible that you’re a victim of a WordPress hack. When someone hacks into your website, they can change WordPress core files, themes, or plugins without your knowledge causing the critical error. Often, the WordPress owner isn’t even aware of the hack, but sometimes the hacker or their malicious code makes a mistake.
If you suspect that you’re the victim of a hack, read the handy NameHero guide on how to clean up your WordPress website from a hack. You might even have to replace all your core WordPress files and in the worst-case scenario, your cPanel files. For an easier approach that might fix the problem, try using the free Jetpack Protect feature.
How to Access Your WordPress Files During the Critical Error
The most frustrating part of the “There Has Been a Critical Error on Your Website” critical error is that it makes it impossible to get into the WordPress admin area.
To access your WordPress site when this happens, you need to modify the files directly from the backend. Here are two ways to do it.
#1. Accessing your Files Using the cPanel File Manager
If you’re a typical user on NameHero, the easiest way to do this is by using the cPanel file manager as shown here:
You can reverse the changes you made to the theme or plugin files that may have caused the critical error in WordPress from here. As mentioned above, it’s best to use this feature to modify the files in the first place vs using the WordPress Built-In Editor to change your WordPress theme or edit WordPress plugins.
#2. Accessing the Files via SFTP
The second way to access your files is through SFTP. You can also do this using plain FTP, which is easier but a lot less secure because the data is transferred over the Internet in plain text. SFTP is a more secure version of FTP, but it takes some work to set up. Here’s how to connect to your website securely using SFTP. You’d then be able to reverse any changes that would cause a critical error here as well.
Summary: Make Sure You Have Backend Access
The “There Has Been a Critical Error on Your Website” error is almost always caused by a plugin or theme file error. When this happens, you need to quickly have access to your WordPress backend files and folders since you’re locked out of the WordPress admin area and unable to fix the critical error as you would expect.
If you have backups enabled, you can recover a previous version of your site via CPanel or ask one of our NameHero support team members to assist you with restoring your WordPress website.
For this reason, it’s best to always edit the files using the file manager or via SFTP. That way, you can reverse the changes easily if you run into a critical error again. However there are certain things like waiting to update a plugin, or avoiding updating a WordPress default theme unless absolutely necessary that can keep you safe as well.
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!