Since WordPress 5.2 there is a built-in feature that detects when a plugin or theme causes a fatal error on your site and notifies you with this automated email. Thanks to WordPress Updates, the old Error Page has gone for good. In simple words, ugly HTTP 500 Error Page is replaced with fancy error page in recent WordPress Versions which can be seen in the following image.

 

The two new messages are:

  • The site is experiencing technical difficulties. (for trying to access public-facing website pages like Homepage or Posts)
  • The site is experiencing technical difficulties. Please check your site admin email inbox for instructions. (for trying to access wp-admin pages)

 

Note: This guide will also work for HTTP 500 errors on the websites which generally means PHP Fatal Errors or Warnings in the backend.

 

Causes

  • Plugin or Theme throwing PHP Errors in backend probably due to PHP incompatibility or conflict with other plugins
  • PHP Limits like max_execution_time, memory_limit, etc are exhausted
  • Recent Plugins or Themes updates/changes on the Website.

 

How to Debug and Fix this issue?

 

Lets us debug the issue by reading the PHP error logs which are generated by the most webservers by default in website directory with name error_log or error.log

 

1. Login to cPanel or FTP and find error_log or error.log

2. Open the log file and scroll to the bottom of the log for most recent PHP Errors and warnings. You can find something similar to the below in the error logs.

 

Log #1

PHP Warning: include_once(): Failed opening '/home/username/public_html/wp-content/plugins/updraftplus/includes/class-backup-history.php' for inclusion (include_path='.:/opt/cpanel/ea-php73/root/usr/share/pear') in /home/username/public_html/wp-content/plugins/updraftplus/class-updraftplus.php on line 96

 

Log #2

PHP Warning: include_once(): Failed opening 'classes/wp-security-backup.php' for inclusion (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/username/public_html/wp-content/plugins/all-in-one-wp-security-and-firewall/wp-security-core.php on line 109
PHP Fatal error: Class 'AIOWPSecurity_Backup' not found in /home/username/public_html/wp-content/plugins/all-in-one-wp-security-and-firewall/wp-security-core.php on line 204

 

Log #3

PHP Fatal error: Uncaught Error: Class 'WP_Smush_Backup' not found in /home/username/public_html/wp-content/plugins/wp-smushit/core/class-wp-smush-modules.php:92
Stack trace:
#0 /home/username/public_html/wp-content/plugins/wp-smushit/core/class-wp-smush-core.php(310): WP_Smush_Modules->__construct()
#1 /home/username/public_html/wp-content/plugins/wp-smushit/core/class-wp-smush-core.php(212): WP_Smush_Core->init()
#2 /home/username/public_html/wp-content/plugins/wp-smushit/wp-smush.php(283): WP_Smush_Core->__construct()
#3 /home/username/public_html/wp-content/plugins/wp-smushit/wp-smush.php(209): WP_Smush->init()
#4 /home/username/public_html/wp-content/plugins/wp-smushit/wp-smush.php(193): WP_Smush->__construct()
#5 /home/username/public_html/wp-includes/class-wp-hook.php(286): WP_Smush::get_instance('')
#6 /home/username/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#7 /home/username/public_html/wp-includes/plugin.php(465): WP_Hook->do_action(Array) in /home/username/public_html/wp-content/plugins/wp-smushit/core/class-wp-smush-modules.php on line 92

 

3. In the above log #1 a plugin named ‘Updraft Plus‘ is throwing PHP Errors. Similarly, in log #2 we can see a plugin named ‘All in One WP Security and Firewall‘ is throwing PHP Errors and for log #3 plugin ‘WP Smush IT‘ is throwing FATAL Errors.

 

4. Similarly, if the theme is throwing PHP errors then it will show up on logs.

 

5. By reading the logs we have a fair idea that what is causing the website to fail.

 

What to do if error_log or error.log file is not generated?

 

If you are unable to find error_log or error.log in your website’s root directory then probably your server has loggings disabled on it. So in this case what can be done is we can enable WordPress debugging options in wp-config.php file. Use your Server’s File Manager or FTP to edit the wp-config.php file and insert the below code.

// Enable WP_DEBUG mode
define( ‘WP_DEBUG’, true );

// Enable Debug logging to the /wp-content/debug.log file
define( ‘WP_DEBUG_LOG’, true );

// Disable display of errors and warnings
define( ‘WP_DEBUG_DISPLAY’, false );
@ini_set( ‘display_errors’, 0 );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( ‘SCRIPT_DEBUG’, true );

 

NOTE:

You must insert this BEFORE /* That’s all, stop editing! Happy blogging. */ in the wp-config.php file.

 

By default “define( ‘WP_DEBUG’, false );” might be there already in wp-config.php file, so you can remove it or change the false variable to true.

 

The above lines of code, inserted in your wp-config.php file, will log all errors, notices, and warnings to a file called debug.log in the wp-content directory.  Now you start debugging using the above information.

 

More information can be found in WordPress Debugging official documentation: https://wordpress.org/support/article/debugging-in-wordpress/

 

Fixing the issue

 

Fix #1 Switch PHP Versions for the website (For both Plugins and Themes creating an issue on the website)

 

In few cases due to PHP incompatibility, the website starts throwing such errors. So, the very first step we will try switching the PHP Version for the website. You can try all the PHP Versions one by one that is installed on your web server.

 

 

Fix #2 Disable the plugin. (Only for plugins creating an issue on the website)

 

If switching PHP Version does not help then you can disable the particular plugin by editing the plugin inside wp-content/plugins directory.

For example, rename updraftplus to updraftplus-backup or updraftplus-disabled.

 

After renaming the plugin’s directory you will be able to login to the wp-admin.

 

It is recommended to reinstall the plugin from WP-Admin Dashboard by removing the Plugin. If you are unable to remove the plugin from Dashboard then try removing it from the FTP/File Manager. In most of the cases reinstalling the plugin fixes the issue.

 

 

What to do if a theme is the real culprit and removing/disabling theme is not possible?

 

or

 

What to do if reinstalling plugin didn’t fix the issue?

 

In some cases, one cannot disable remove the theme as it might break the customisations done on the website and there can be cases where reinstalling the plugin didn’t fix the issue.

 

The next steps are to connect with your web/plugin/theme developer with the error logs for further investigation.

Was dit antwoord nuttig? 0 gebruikers vonden dit artikel nuttig (0 Stemmen)