You will receive a ‘There has been a critical error on this website’ notification if your website has one or more backend problems:
- PHP malfunctioning
- Insufficient memory limit
- Broken plugin, theme or code somewhere on the website
- The plugins are not in sync with each other and are hindering each other’s performance
- The database is corrupt
Fixing this error is relatively easy and doesn’t require any in-depth technical knowledge of the backend. That being said, if you are unsure how to proceed, you should take the help of a professional.
Here are some ways you can troubleshoot the ‘There has been a critical error on this website’ issue.
Enable Debug in WordPress
You should start the troubleshooting by first activating the Debug mode in WordPress. With the Debug mode, you can identify and remove the errors on the website. Here’s how to enable the Debug mode in WordPress:
- Connect your site using the FTP.
- Now, find the wp-config.php file in the root folder and open it with any text editor. Right-click on the file and then click on Edit.
- Next, place the following at the bottom of the page, just before the last message:
define(‘WP_DEBUG’, true );
define(‘WP_DEBUG_DISPLAY’, false );
define(‘WP_DEBUG_LOG’, true );
You will have successfully enabled debugging on the website and you can see all errors on the log. To find the debug log, head to the wp-content folder and search for debug.log. Report this log to the professionals for more support if you are not sure what to do with it. Or, if you are an expert backend developer, you can rectify each error on your own.
Also read: Fix: error: member not found: firebaseappplatform.verifyextends
Roll back website
If you feel that the new upgrades on your website are causing the error, then you should revert the website back to the last backup. This process is not a sure-shot way of fixing the error but can help you to trace its origins.
There are several ways to restore the backup. If you have been using a plugin for this purpose, follow the instructions or you can access the restore option from the website dashboard if your web host provider has included backup options by default.
Revert to a default theme
If a faulty and unoptimized theme is the culprit, then you should temporarily delete the theme and try to revert the website back to the default theme.
Make sure to first back up your site so that you do not lose any custom configurations. Go to Appearance > Theme > Click on the theme > Delete.
If you can’t see the Delete option, try to switch to a different theme. You could use easy-to-go themes like Twenty Twenty-One or Twenty-Twenty.
Although plugins make life easier, they can also cause tons of errors if not properly optimised. In WordPress, you can add dozens of plugins and trying to locate which plugin is the likely cause of the error can be disheartening.
But there is a way to sort things out. Just disable every plugin on the website and then enable them one at a time. This way, you will be able to pinpoint exactly which plugin is causing the problem.
- Go to the dashboard and then head to Plugins > Installed Plugins.
- Now, check on the box named Plugin to select all the plugins.
- Next, click on Bulk Actions > Deactivate.
This process will deactivate all the plugins. Now, activate each plugin by clicking on the Activate option and check for errors. Once you locate the malfunctioned plugin, either uninstall it and reinstall it again or delete the plugin and find a suitable substitute.
Also read: How to fix ‘iframe refused to connect’ error?
Increase the PHP memory limit
As the web server has limited RAM, WordPress restricts the memory used by the PHP script. When this limit is exceeded, you might see the ‘There has been a critical error on this website’ screen.
Therefore, you should raise the PHP memory limit so that the PHP scripts could be processed. Here are the steps to do so:
- Open the website via FTP.
- Locate and open the wp-config.php file.
- Write or copy the following code at the end of the document:
define( 'WP_MEMORY_LIMIT', '256M' );
This will increase the PHP limit to 256 MB. However, for heavy plugins, this might not be enough. So, you can try to increase the memory to 512 MB. Just write 512M in place of 256M in the code above.
Upgrade the PHP version
You should upgrade the existing PHP version to a new one as soon as you can to avoid any hassles. To find the existing PHP version, follow the steps below:
- Login to admin and then go to Tools > Site Health and switch to the Info tab.
- Next, scroll down and then expand the Server tab to see the current PHP version.
All the WordPress hosting companies like HostGator, Bluehost, and SiteGround, among others, allow you to easily upgrade the PHP version. Follow the directives of the hosting provider to upgrade the PHP.
After you have upgraded the PHP, head to the website and make sure that all the functions are working properly.
Also read: How to install PHP in Ubuntu?
A cache is a small memory that contains all the necessary files required to upload the website faster. However, a corrupt cache can cause problems with the website. Hence, it would be wise to clear the cache once in a while.
How you will clear the cache will depend on your hosting provider. Usually, you will see options like Purge All or Purge all cache.
Scan for malware
Another reason for the ‘There has been a critical error on this website’ screen is the presence of malware. If you notice any unwanted PHP script on the website and you can’t locate its origins, then it is malware and you should contact your hosting provider for further assistance.
Also read: How to install PHP on Windows manual?
Deputy Editor at Candid.Technology. Hemant writes at the intersection of tech and culture and has a keen interest in science, social issues and international relations.
You can contact him here: [email protected].me