fix critical error on wordpress

How to Fix the “There Has Been a Critical Error on Your Website” Error in WordPress?

You almost get frightened when you see any error on your WordPress site. A frightening error most WordPress users face is “There has been a critical error on your website”.

This means your site is down and is quite terrifying for you being the website owner. 

When such an error appears on your website, users can’t visit your website, and even you can’t log into your WordPress admin.

Because you are blocked from the front end, you must find ways to fix this error. Luckily, there are proven methods to resolve this issue.

Here, you can go through troubleshooting steps to fix this issue, so your site is up & running in minutes.

Why Does “There has been a critical error on your website” appear on your site?

WordPress errors like the one we are discussing here block you from accessing the WordPress admin dashboard.

wordpress critical error

There can be several reasons for the error to occur on your WordPress site. This usually happens when a PHP script stops running due to a fatal PHP error. 

When WordPress detects a PHP issue, you get notified on your admin email address. 

The email contains the error caused by a plugin or theme not working correctly. More details like which line has an error are explained in the email.

It may also be caused due to database corruption or insufficient memory. 

Also, the email consists of a recovery link to access your site in recovery mode. You can log into your WordPress dashboard using the recovery link to resolve the issue.

How To Fix A Critical Error Issue on Your WordPress website?

Here are several ways to resolve a critical issue. Before you make any changes, do backup your website, or you may lose your data. 

Since the critical error doesn’t allow you to log in to your WordPress dashboard, you will have to access your site via FTP.

To access FTP, you must log in to your hosting account or install third-party software like FileZilla.

Debug Mode

One of the foremost and crucial steps to resolve the issue is to enable the Debug mode. The debug mode traces the root cause of the error. You need to enable the debug log as you cannot access your WordPress admin dashboard.

When the debug mode is on, visitors can also see it, so remember to disable it when you are done. 

To manually enable the debug mode, follow these steps:

  • Access your site via FTP. If you don’t have access to a hosting account, then use FileZilla.
  • Locate the wp-config.php inside FTP and open it via text editor or IDE.
  • Inside the file, you need to copy and paste the following code at the bottom just before the final line of code.

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

define( ‘WP_DEBUG_LOG’, true );

  • Once you are done, save the file and close it. Debugging will be on, and the errors will get written on the log. The debug.log can be found inside wp-content.
  • Find out the cause pointing towards themes or plugins. If you are not a technical person, take help from someone or reach out to the support team. 
  • Once you have fixed the issue, remove the above lines and save them. This will disable the debug mode.

Default Theme Activation

When you have performed the debug, you will identify the issue causing the critical error. Sometimes it could be due to the theme.

In such a case, you should revert to a default theme in your WordPress admin and delete the existing theme. 

Always ensure a site backup, so you don’t lose your theme files.

WordPress comes with pre-installed themes like Twenty-twenty, or twenty-twenty-one. You can choose anyone as the default theme.

Go to Appearance > Themes

You first need to activate the Twenty Twenty-one theme to delete the current theme. Then click on the current theme, and at the bottom, click on Delete. 

This step can be performed only if you can access your site’s admin panel.

To delete the theme via FTP, follow these steps:

  • Download FileZilla and connect your site with FTP credentials.
  • Go to wp-content>themes, wherein you will find all the themes on your site. The one that is activated can be either renamed or deleted permanently. Renaming a theme allows you to revert to the same theme later.
  • If there is no default theme, you can manually download the theme files and place it in the Theme folder via FTP.

Once you set the default theme, you can check your site. If your site works fine, it means the problem was with your theme.

You can restore your theme by changing the folder name back to its original name.

Plugins Disable

Plugin compatibility issues with the latest WordPress version often causes the critical error. Now every WordPress user installs dozens of plugins for site management.

Plugins for security, landing page & form builder, Google Analytics, etc., get installed. But some of these plugins crash because they are incompatible with either the theme or WordPress version.

Identifying such a plugin causing the error is not an easy task.

The best way is to disable all the plugins and activate them.

To disable all the plugins in bulk, go to Plugins > Installed Plugins. Select all the plugins and then choose to deactivate. 

Now you can check your site and then start activating the plugins one by one. 

To disable the plugins via FTP, follow these steps:

  • Connect your site with FTP.
  • Inside the wp-content folder, locate the plugins.
  • To bulk disable the plugins, simply rename the plugins folder to a new name like plugins_temp. 
  • Now check whether your site is up and running.
  • You should now be able to log in to your admin dashboard. From the dashboard, you can activate the plugins one by one.

Malware Removal

It might be possible that your site files got infected with malware. But how would you identify that the critical error is caused due to malware?

You can notice strange PHP scripts that can’t be traced. Removing the malware is not everyone’s cup of tea. 

You can’t touch the core files of your WordPress site, as deleting them could result in a disaster. 

But to identify malicious files, you need to be an expert developer. If you are not a developer, simply contact your hosting manager and get premium support to remove malware.

Other ways to fix the critical error

The cache is what speeds up your WordPress site. But sometimes, a critical error is caused due to the cache being corrupted. 

The best solution is to clear the cache using a cache plugin, and your site will be live again. 

Another major issue causing the critical error is the PHP version. WordPress keeps updating to the new version, so your site’s PHP version should also be updated.

Old PHP versions have compatibility issues with WordPress, so your site might be in trouble. 

The PHP version depends on your website hosts, so always purchase a hosting plan with the latest PHP version.

Conclusion

Critical errors on your WordPress site might be caused due to several reasons. We covered some major reasons and the ways to resolve them.

If the PHP memory limit has exceeded, you need to increase the memory size.

If nothing above works, then you need technical support from your host.