WordPress errors are something everyone tries so hard to avoid, but even for the most skilled developers – they do happen! Today we will cover everything you need to know to fix (and understand) the error “The site is experiencing technical difficulties”.
There was a time this would not even be an error and you would just get a white screen – then scratch your head wondering what was up. But WordPress realized that there was confusion and frustration with this so they changed to to now show the technical difficulties message.
WordPress version 5.2 tries to catch the PHP errors which are the cause of the WSoD.
The result is a new message “The site is experiencing technical difficulties”.
This is much better than a blank screen but it seems that a lot of experienced WordPress users are still unaware of this new message.
Who reads WordPress update blogs anyway, huh?
How to Find the Error
PHP is used in the WordPress core, themes and plugins, so that doesn’t narrow things down really.
The best place to start is by placing WordPress into debug mode and having a look at the log file it generates.
Placing WordPress in Debug Mode
Locate your wp-config.php file.
Your best bet will be to use File Manager in your cPanel hosting account, or equivalent.
The wp-config.php file should be in your root hosting folder and it contains the configuration settings for WordPress.
Add the following lines to the file, somewhere above the line /* That’s all, stop editing! Happy blogging. */
define( 'WP_DEBUG_DISPLAY', false );
Once the lines have been added and the file has been saved, hit refresh on any page from your site.
In File Manager, navigate to the /wp-content/ folder and view the file debug.log.
Look in this file for a line that says “PHP Fatal Error:”.
Here is an example of what you will see.
PHP Fatal error: Cannot redeclare bp_members_screen_display_profile() (previously declared in /.../buddypress/bp-members/screens/profile.php:22) in /.../buddypress/bp-members/screens/profile.php on line 32
The line in debug.log will give you an exact file and line number where the error occurred.
You can use this to identify whether the error is in a plugin, theme or WordPress core.
Clean Up Debug Code
Remember to remove the debug code lines from the wp-config.php file after you are finished.
The Alternative Fix Method
If the debug method it too confusing for you to wrap your head around, there is another way of resolving the error. It takes a bit more time but will work just fine.
Resolving Theme Conflicts
Because of the error you won’t be able to get into the admin back-end to switch themes.
You will have to do this using your hosting providers file manager system.
Find the current theme folder that your site is using in /wp-content/themes and rename the directory with a post-fix of “OLD”.
For example if your site is running the Astra theme, rename the folder “astra” to “astraOLD”, then refresh the front page of the site which has the error on it.
Don’t worry, you won’t lose all your theme settings. They will be available when you restore the theme folder name at the end if this process.
Note: you will need to have at least one other default theme, like Twenty Nineteen or Twenty Sixteen, in your themes folder for this to work.
If the error is still there after you refresh the font page of the site then the error is not in your theme and you can rename your theme folder back to its original spelling.
If the error disappears and you see your site using one of the default themes, then your theme has the error in it.
You can now access the admin area to update your theme or reach out to the theme developer or company for an update.
Resolving Plugin Conflicts
If the theme isn’t the problem then chances are it will be a plugin at fault.
The quickest way to do this is to use the hosting account file manager application.
Navigate to /wp-content/plugins and rename the “plugins” folder to “pluginsOLD”.
Now refresh the site and login to the admin dashboard and navigate to the Plugins view.
You will notice that all the plugins have been deactivated because WordPress can’t find them as we renamed the folder.
Go back to file manager and rename “pluginsOLD” to “plugins”.
Go back to the plugins view in the admin dashboard and refresh the view.
Now, start to activate each plugin one and a time, refreshing the front of the site until the error message appears again.
Bingo! The last plugin you activated is the one that has the error.
Now you know which plugin is causing the issue you can reach out to the developer or company where you purchased it from for a patch, or in the worst case scenario, find an alternative plugin.
Upgrading Your PHP Version
WordPress has increased the recommended version of PHP to version 7.2 and plugin and theme authors are taking advantage of the new functions available in PHP 7.
You may find that the PHP fatal error in the log file is generated because the old PHP 5.6 function doesn’t exist any more.
This is called deprecation, where old functions are removed in favour of newer, better functionality.
It’s time to upgrade your PHP version from 5 to 7 and you can also do this easily from cPanel.
If you don’t have access to cPanel, contact your hosting provider and they will help you to upgrade.
As of the time of writing, I recommend that you upgrade to PHP 7.3.
Disabling the Fatal Error (WSOD) Protection
If you are a developer and are looking for that additional granularity over the new PHP fatal error protection, you can disable it in a couple of ways.
- Edit your wp-config.php file and add the following line:
define( ‘WP_DISABLE_FATAL_ERROR_HANDLER’, true )
- In your theme’s functions.php file add the following line:
add_filter( ‘wp_fatal_error_handler_enabled’, ‘__return_false’ );
The second method returns false to the filter handler. You could also use the same function to parse the error output.
If you have followed the instructions here, hopefully, you will be back up and running.
Now is the time to make sure that your backups are running properly, just in case you need to use them as a last resort if this sort of stuff happens again!
Need help with your WordPress site?
We can’t wait to talk about your project. Let’s set up a call.