How to fix “A critical error has occurred on your website” error in WordPress

As a WordPress site owner, your site may occasionally experience downtime caused by one or more critical errors in WordPress. When this happens, you will see the dreaded error message that says “A critical error has occurred on your website” when you try to access or view the site.

Critical error message in WordPressCritical error message in WordPress
Critical error message in WordPress

With this message, WordPress is practically telling you that there is a fatal error on your website. During this period, the site will remain inaccessible to visitors and you may be blocked from accessing the admin panel.

Fortunately, this error is easy to fix and in this article we will look at the possible fixes for the WordPress critical error. First, let’s take a look at why this error might occur in the first place.

Causes of the error “A critical error has occurred on your website”.

The website critical error in WordPress can be caused by one or more things, but unfortunately the error text is too vague to give an idea of ​​what exactly went wrong with your site. Therefore, it is up to you to understand the reason behind it.

If you encounter this error while setting up WordPress for the first time, it is very likely that you have specified the wrong database information or added an inaccessible database. In this case, you will need to set accurate database details within the file wp-config.php file of your WordPress installation.

In addition to setting incorrect database information, the WordPress critical error can also result from the following issues:

  • damaged database
  • poor hosting provider
  • web server lagging or overloaded
  • Corrupted website cache or PHP code (including plugins and themes)
  • server file corruption
  • other server-related problems

To help fix the problem, WordPress detects when a critical error occurs and sends an email notification to the administrator’s email address. This email contains details of the error and a link to access the site dashboard in recovery mode.

Please note that this email may sometimes be sent to your spam folder. Therefore, be sure to check there if you don’t find it in your main inbox. If you don’t get the email at all, you will need to figure out the problem yourself and fix it.

How to fix the error “A critical error has occurred on your website”?

Correcting the error first requires you to know what caused it. In the notification email sent by WordPress, you will be shown the damaged PHP files and even the line of code to fix. However, if you haven’t received this message, don’t worry.

Below are eight methods to fix critical errors in your WordPress site. Click the link below to jump to a particular section:

1. Deactivate your site’s plugins

Damaged plugins are one of the most common causes of WordPress website critical errors. If the WordPress critical error occurred right after installing a plugin, you will need to deactivate that particular plugin and see what happens next.

You can deactivate a plugin from the plugins area in your WordPress admin panel. But, in case you are prevented from accessing the backend, you will need to manually deactivate the plugins.

You can find all the plugins used on your site by navigating to wp-content> plugin from the root directory of your WordPress site.

Directory of pluginsDirectory of pluginsDirectory of plugins
Directory of plugins

There all you simply have to do is rename the plugin. This ensures that WordPress loads without the problematic plugin the next time you restart your WordPress site, which should eliminate the error.

If you’re not exactly sure which plugin is responsible, you can just rename them one by one until you find the culprit.

For hosted WordPress sites, you will need to log in via FTP. Consult your hosting provider for information on how to do this.

2. Check the error logs

Another method to verify the root cause of the critical error is to inspect the file error_log file, which stores PHP error information on your WordPress site. You can find this file inside wp content folder of your WordPress installation.

The file lists all errors on your WordPress site and the time each occurred. Additionally, each error contains detailed information about the responsible source file and even the line of code you will need to fix.

3. Go back to a default theme

Themes are responsible for the look and feel of WordPress websites. As they form the foundation of your site, you are very likely to get a critical error if there are conflicts in the PHP code that powers your site’s theme.

To check if a theme is responsible for your WordPress error, change the current theme to a default one like Twenty Twenty. If you can log in to the admin panel, go to Appearance> Themes and look for a default theme to use.

Twenty twenty themeTwenty twenty themeTwenty twenty theme
Twenty twenty theme

If you don’t have access to the admin panel, you will need to manually delete the theme folder in wp-content> themes. But before you do that, be sure to back up your site so you don’t permanently lose your theme files.

4. Restore your website from the most recent backup copy

The mere possibility of your WordPress site experiencing a critical error is reason enough to back up your site regularly. Restoring a recent backup may be all you need to get your website up and running again, in the shortest time possible.

The process of restoring to a backup depends on how the backup was performed. If you used a backup plugin like UpdraftPlus, go to the backup plugin panel and find the restore functionality. The interface varies depending on the plugin you are using, but typically you only need to select a backup file to restore the site.

If you are using a hosting platform that provides regular backups, you should be able to restore your website from the hosting dashboard or admin panel.

5. Enable Debug Mode for WordPress

In debug mode, WordPress can automatically detect PHP errors in both the main software and the themes and plugins used on the site.

To enable debug mode on your WordPress site, open the wp-config.php file with a text editor or IDE and include the following code at the bottom of the file:

The first setting above is what actually puts your site into debug mode. The rest simply defines how the registers will be shown.

Save the file and restart your website. The errors will be added to the log in a debug.log file, which you can find in the wp-content folder. Inspect the logs and try to understand the theme or plugin responsible for the error.

Make sure you remove similar lines of code when you’re done debugging.

6. Increase the upper limit for the upload file size

If you get the critical error message when you try to upload a file to WordPress, it is probably because the maximum upload file size is too small. If so, you can fix the problem by increasing the limit.

You should always first compare the current maximum upload size with the size of the file you want to upload. The maximum size is shown to you at Media> Add page, just below the file upload section.

Check the maximum file sizeCheck the maximum file sizeCheck the maximum file size
Check the maximum file size

To increase the limit, open the wp-config.php file with a text editor and set the new maximum upload size to ini_set() as shown below:

In the line above, we also increase the maximum size for text processing.

7. Empty your site’s cache

Caching helps your website load faster by temporarily storing important and frequently used data. However, as data accumulates, it is possible for the cache to become corrupted. When this happens, you will get a critical error on your site.

This problem can be solved by clearing the cache. Any outdated data will be deleted and your site should be up and running again.

If you are using a plugin like W3 Total Cache, go to the plugin panel in your WordPress dashboard and look for the feature to clear the cache. You may need to log in using the link in the WordPress email to access your site’s admin panel.

8. Update your PHP version

Using an old version of PHP is a common cause of critical errors on a WordPress site. For this reason, you should always use the latest stable version of PHP for your WordPress site. Currently, it is between PHP 7.4 and 8.0.

Stable versions are not prone to errors like previous versions (PHP 5.x). Plus, you don’t have to worry much about plugin and theme compatibility. If you are using an older version of PHP, upgrade it to PHP 7.4 or higher. But before you do that, make sure you’ve backed up your website.

On most hosts, you can update PHP from the hosting dashboard.


The WordPress critical error is one of the most common errors in WordPress, and fortunately, it is very easy to fix. In this article, we’ve looked at several ways to fix this error and bring your website back to life.

To recap briefly, they are as follows:

  • Deactivate your site’s plugins
  • Check the error logs
  • Go back to a default theme
  • Restore your website from the most recent backup copy
  • Enable Debug Mode for WordPress
  • Increase the upper limit for the upload file size
  • Clear your site cache
  • Update your PHP version

Source link

By LocalBizWebsiteDesign

Leave a Reply

Your email address will not be published. Required fields are marked *