Critical Error in WordPress

How to Fix the Critical Error in WordPress [06 Methods]

Last updated on

by


WordPress powers millions of websites worldwide, ranging from personal blogs to large-scale enterprise solutions. However, even with its widespread use and reliability, WordPress can sometimes encounter issues.

One of the most troubling problems is the dreaded message: “There has been a critical error on this website. Please check your site admin email inbox for instructions.”

If you’ve come across this error, it’s essential to address it promptly to restore your website’s functionality. In this article, we’ll walk you through six effective methods to resolve the critical error in WordPress.

We’ll also explore the underlying causes and how to prevent this issue from occurring in the future.

Let’s dive right in.

What is a Critical Error in WordPress?

A critical error in WordPress occurs when the platform cannot load all the scripts it needs to operate correctly. This issue disrupts your website’s functionality and demands immediate attention.

In the past, encountering this issue often resulted in a fatal error message or the infamous white screen of death, leaving many beginners uncertain about how to resolve it. To assist users, WordPress now identifies when a plugin or theme triggers a critical error and sends a notification to the administrator’s email address. If you don’t find the email in your inbox, remember to check your spam folder.

The email provides specific details about the error, often pinpointing a problematic plugin, theme, or even issues like database corruption or insufficient memory. Additionally, it includes information such as the exact line of code causing the issue. A recovery link is also provided, enabling you to access your site in recovery mode. By using this link, you can log into your WordPress dashboard and start fixing the error.

What Causes the Critical Error in WordPress?

The WordPress critical error message can be frustrating because it provides little information about what went wrong. At its core, this issue arises when PHP code cannot execute properly. It could be due to a faulty theme or plugin, exceeding the wp_memory_limit, or other technical issues. If not resolved quickly, you might encounter the following problems:

  • White Screen of Death (WSoD): This error replaces your website’s content with a blank screen. It often occurs due to coding errors or compatibility issues.
  • Internal Server Errors: The HTTP 500 error signals that the server encountered an unexpected problem and couldn’t process the request.
  • Database Connection Errors: The message “Error establishing a database connection” indicates that your site is unable to communicate with its database, affecting both the website and admin dashboard.
  • Syntax or Parse Errors: Messages like “Parse error: syntax error, unexpected” point to mistakes in PHP code. These errors often involve incorrect symbols or typos in the code.

Common Causes of WordPress Critical Errors

  • Corrupted Core Files: Issues with core files can occur during database updates or directory permission changes.
  • Faulty Themes or Plugins: Automatic updates or incompatibilities often cause these elements to break and lead to critical errors.
  • Syntax Errors: PHP script errors may arise from typos, missing symbols, or incorrect code structures.
  • Malware Infections: Malicious code from unsecured plugins or themes can corrupt database information, making your site non-functional.
  • PHP Memory Limits: Resource-heavy plugins combined with low server memory limits can crash your site.
  • Outdated PHP Versions: Running outdated PHP versions can create vulnerabilities and disrupt site functionality when unsupported features are used.

Understanding these causes can help you identify and resolve the issue, restoring your site’s functionality.

6 Ways to Fix the Critical Error in WordPress

We’ll now show you six quick fixes to help you solve the “There has been a critical error on this website” error.

Method #1: Check WordPress Error Logs

Start by checking the error log file, which records PHP error details.

To access it, use an FTP client such as FileZilla and navigate to the public_html directory. Within this folder, locate the error_log file.

Open the file and scroll to the bottom to find the most recent error entries. These will include timestamps, helping you pinpoint the specific issue causing your site’s error.

Method #2: Enable Debug in WordPress

WordPress includes a built-in debugging tool to identify coding errors in its core software, themes, and plugins. When debug mode is activated, PHP issues on your site become visible, helping you trace their source.

To enable debug mode, access the wp-config.php file in your public_html directory using an FTP client, as shown in the screenshot below:

Open the file and add the following lines of code just above the comment /* That’s all, stop editing! Happy publishing. */:

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

define( ‘WP_DEBUG_LOG’, true );

Save your changes and upload the updated file back to the server. Once enabled, debugging will log errors to a file named debug.log located in the wp-content folder. You can review this file to diagnose the issues affecting your site.

Method #3: Switch to a Default Theme

To troubleshoot the critical error, try switching your WordPress theme to a default one. This can help if the issue stems from your current theme’s code.

Start by downloading a fresh copy of the Twenty Twenty-Four theme from the WordPress.org themes directory.

Once downloaded, unzip the theme file on your computer.

Next, use an FTP client or your hosting account’s File Manager to connect to your WordPress site. Navigate to the /wp-content/themes directory, where all installed themes are stored. For backup purposes, download all the theme folders to your computer.

After backing up, delete all theme folders from your website. This will leave your site without a theme.

To resolve this, upload the default theme folder you downloaded earlier.

Once the new theme is uploaded, visit your website again. If your previous theme caused the critical error, it should now be resolved, and your site should be accessible.

Method #4: Deactivate All the Plugins

A plugin is often responsible for triggering a critical error in WordPress. If you have multiple plugins installed, identifying the one causing the problem might feel overwhelming. However, a straightforward way to pinpoint the issue is to deactivate all plugins and check if the error resolves. If it does, reactivate them one at a time until you identify the problematic one.

To do this, connect to your website using an FTP client or your hosting account’s File Manager. Navigate to the /wp-content/ directory and locate the plugins folder. Right-click on the folder and select the Rename option.

Rename the folder to something like plugins.old.

Renaming the folder automatically deactivates all plugins because WordPress cannot locate the plugins folder to load them. Once deactivated, visit your website to see if the error is resolved.

NOTE: If the error is fixed, rename the plugins.old folder back to plugins. This will allow WordPress to recognize the folder again. You can then reactivate your plugins one by one through the dashboard, testing your site each time to find the plugin causing the issue.

Method #5: Increase PHP’s memory limit

In many cases, the PHP memory limit is the underlying cause of the “There has been a critical error on this website” message, even if a plugin or theme appears to trigger the issue.

The PHP memory limit sets a restriction on how much memory a single PHP script can use on your web server. When this limit is exceeded, your site may display a critical error or a white screen of death.

To increase the PHP memory limit, access your site using an FTP client and locate the wp-config.php file in the root directory of your WordPress installation. Open the file and add the following code snippet just before the last line:

define( ‘WP_MEMORY_LIMIT’, ‘128M’ );

After adding the code, save the file and upload it back to the server. This change increases the memory limit, potentially resolving the critical error on your website.

NOTE: By increasing the PHP memory limit you can also fix the “Image Upload Issue in WordPress.”

Method #6: Run a Malware Check

Malware can sometimes be the underlying cause of the “There has been a critical error on this website” message, especially if you notice unfamiliar PHP scripts that don’t belong to your plugins or theme. Addressing malware issues becomes more difficult if you’re locked out of your website and unable to conduct a scan.

Malware often disguises itself by adding suspicious files or altering PHP scripts, embedding hidden code within them. Identifying these malicious modifications can be tricky if you’re not a developer, and deleting random core files could lead to further issues.

If malware is causing a critical error, reaching out to your web host for assistance may be the most effective solution. Many hosting providers offer tools or services to scan and remove malware from your site safely.

Conclusion

You don’t need to panic when you encounter any critical error in WordPress such as, “There has been a critical error on this website. Please check your site admin email inbox for instructions.“ message.

By understanding the root causes and following the troubleshooting methods discussed in this article, you can restore your website’s functionality and prevent similar issues in the future.

Key Takeaways for Fixing the Critical Error in WordPress:

  • Regularly back up your website to safeguard your data and restore functionality quickly.
  • Use WordPress recovery mode to identify and address issues caused by plugins or themes.
  • Check error logs and enable debugging to diagnose PHP-related problems.
  • Increase your PHP memory limit to avoid resource-related errors.
  • Scan your website for malware and seek professional assistance if necessary.

Which method worked best for you? Have you encountered any challenges while resolving the critical error? Share your experiences and solutions in the comments below! Your insights can help others facing similar issues.