how-to-fix-the-critical error in wordPress -step by step
Trending Topic

How to Fix The Critical Error in WordPress (Step by Step)

Author: Brian Denim

  

Last Updated: January 11th, 2023

If you’re a WordPress website owner, you may have encountered a “Critical Error” that prevents your site from loading or functioning properly. This error can be a source of significant frustration, but the good news is that it’s often fixable with a little bit of troubleshooting. In this detailed guide, we’ll walk you through the steps to diagnose and resolve the issue, ensuring that your WordPress site gets back on track quickly.

What is the “Critical Error” in WordPress?

A Critical Error in WordPress is a generic error message that usually indicates something is wrong with your website’s code, plugins, themes, or database. When this error occurs, your website might display a message like:

“There has been a critical error on this website. Please check your site admin email inbox for instructions.”

This error can happen for several reasons, ranging from plugin conflicts and theme issues to server problems. While the cause is often unclear, WordPress tries to notify the site administrator about it via email.

In this guide, we’ll break down the process of resolving the issue with clear, easy-to-follow steps.

Step 1: Enable WordPress Debugging to See the Error Details

The first step in resolving a critical error is to understand what’s causing it. By default, WordPress hides error messages from the frontend of the website for security reasons, but you can enable debugging to get more detailed error logs.

1.1 Edit the wp-config.php File

  1. Access your website’s files: You can do this through your hosting control panel’s File Manager or via an FTP client like FileZilla.
  2. Locate the wp-config.php file: This file is typically located in the root directory of your WordPress installation.
  3. Edit the wp-config.php file: Open the file and search for the following line:
    /* That’s all, stop editing! Happy publishing. */
  4. Add the following debugging code above that line:

    define( ‘WP_DEBUG’, true );
    define( ‘WP_DEBUG_LOG’, true );
    define( ‘WP_DEBUG_DISPLAY’, false );

    WP_DEBUG: Enables debugging mode.
    WP_DEBUG_LOG: Logs errors to a debug file in the wp-content folder.
    WP_DEBUG_DISPLAY: Disables error display on the frontend but still logs them.
  5. Save the file.

1.2 Check the debug.log File

After enabling debugging, you can check the error logs for more information:

  1. Navigate to your wp-content directory.
  2. Look for the debug.log file.
  3. Open the file to see detailed error messages, which should help identify the root cause of the critical error.

Step 2: Check Your Email for Error Details

When a critical error occurs, WordPress may also send an email notification to the website admin. This email usually contains details about the error, including:

  • The plugin or theme causing the issue.
  • A link to the WordPress recovery mode, allowing you to disable problematic plugins or themes directly.

If you’ve received an email about the critical error, check it thoroughly for specific details on what needs fixing.

Step 3: Deactivate All Plugins

One of the most common causes of critical errors is a plugin conflict or a malfunctioning plugin. If the error is caused by a plugin, deactivating them can help fix the issue.

3.1 Deactivating Plugins via the WordPress Dashboard

If you can access the WordPress admin dashboard, follow these steps:

  1. Log into your WordPress admin area (yoursite.com/wp-admin).
  2. Navigate to Plugins > Installed Plugins.
  3. Select all plugins by checking the box at the top of the list.
  4. Choose Deactivate from the bulk actions dropdown and click Apply.

This will deactivate all plugins. If your site loads properly after deactivating them, you can proceed to reactivate the plugins one by one to identify the problematic one.

3.2 Deactivating Plugins via FTP

If you can’t access your WordPress admin, you can deactivate plugins via FTP:

  1. Connect to your website’s files using FTP.
  2. Navigate to the wp-content folder.
  3. Rename the plugins folder to something like plugins_disabled.
  4. Try accessing your website again. If the site works, you know a plugin was causing the error.
  5. Rename the folder back to plugins and then reactivate each plugin one by one to identify the culprit.

Step 4: Switch to a Default WordPress Theme

If the issue isn’t caused by a plugin, the next thing to check is your theme. Themes can sometimes conflict with plugins or contain errors that lead to critical issues.

4.1 Switch to a Default WordPress Theme via the Dashboard

If you can access the dashboard:

  1. Go to Appearance > Themes.
  2. Activate a default WordPress theme like Twenty Twenty-One or Twenty Twenty-Two.
  3. Check if the error persists. If the error is resolved, your theme is likely the cause.

4.2 Switch to a Default Theme via FTP

If you can’t access the WordPress admin, you can change the theme via FTP:

  1. Connect to your website’s files via FTP.
  2. Navigate to the wp-content/themes directory.
  3. Rename your active theme’s folder to something like theme_old.
  4. WordPress will automatically fall back to a default theme if it’s available.
  5. Visit your site to check if it resolves the error.

Step 5: Increase PHP Memory Limit

Another potential cause of critical errors is a low PHP memory limit. If your website exceeds the allocated memory limit, WordPress may display a critical error.

5.1 Increase PHP Memory Limit in wp-config.php

  1. Open your wp-config.php file again.
  2. Add the following line above the “That’s all, stop editing!” line:
    define('WP_MEMORY_LIMIT', '256M');
  3. Save the file.

This increases the memory limit to 256 MB. If the error was caused by memory exhaustion, this should resolve the issue.

5.2 Increase PHP Memory Limit via .htaccess (if wp-config.php method doesn’t work)

  1. Open the .htaccess file in your root directory.
  2. Add the following line at the end of the file:
    php_value memory_limit 256M
  3. Save the file.

Step 6: Reinstall WordPress Core Files

Sometimes, the critical error can be caused by corrupt WordPress core files. Reinstalling WordPress can help restore missing or corrupted files.

6.1 Reinstall WordPress via the Dashboard

  1. Go to Dashboard > Updates.
  2. Click on Reinstall Now to reinstall the WordPress core files.

6.2 Reinstall WordPress Manually via FTP

  1. Download the latest version of WordPress from wordpress.org.
  2. Unzip the downloaded file.
  3. Using FTP, upload the wp-admin and wp-includes folders from the new WordPress download to your site, replacing the existing ones.

Step 7: Check for Server Issues

If none of the above steps resolve the issue, the problem might be related to your server environment. Common server-related issues include:

  • PHP version compatibility: WordPress requires a specific PHP version (usually PHP 7.4 or higher).
  • File permissions: Incorrect file permissions can prevent WordPress from functioning properly.
  • Server timeout: Long-running processes can cause timeouts, resulting in a critical error.

7.1 Check PHP Version

Make sure your hosting server is running a supported PHP version. You can usually check this in your hosting control panel under the PHP Settings or PHP Info section.

7.2 Check File Permissions

Ensure that your WordPress files and directories have the correct permissions:

  • Files should have 644 permissions.
  • Directories should have 755 permissions.

You can adjust these using an FTP client or the hosting control panel’s file manager.

Step 8: Contact Hosting Provider

If you’ve tried all the steps above and the issue persists, it might be time to reach out to your hosting provider. They can check server logs for issues, identify server-side problems, and even assist with restoring a backup of your site.

Conclusion

A critical error in WordPress can be stressful, but with the steps outlined in this guide, you should be able to resolve the issue systematically. Whether it’s a plugin conflict, a problematic theme, or server issues, diagnosing the root cause is key to getting your site back up and running.

By enabling debugging, checking email notifications, deactivating plugins, switching themes, increasing the PHP memory limit, and reinstalling WordPress core files, you should be able to pinpoint and fix most critical errors. If all else fails, don’t hesitate to reach out to your hosting provider for further assistance.

By taking a methodical approach, you’ll ensure that your website continues to function smoothly, without the threat of critical errors interfering with your visitors’ experience.

Read this also: WordPress Launches Old Tickets Trac Triage Sessions

Brian Denim
facebook icon linkedin icon

Brian Denim

Brian Denim is a WordPress expert and tech enthusiast. He helps others optimize and enhance their WordPress websites through writing, speaking engagements, and consulting. Brian is dedicated to sharing his knowledge and helping others achieve their online goals.

Subscribe Newsletter

Fill in your email address to subscribe to this blog and start receiving email updates of WordPress tips, news and new content.