WordPress critical error after a PHP update: how to get your site back and find the cause
You switched PHP in your hosting panel, reloaded the site, and now every page says "There has been a critical error on this website." The fastest fix is to go back to the PHP version you had before. Change it back yourself or ask your host. Then find the plugin or theme that broke, on a staging copy, before you try the new version again.
WordPress's own troubleshooting guide says the message means something in your site caused a critical error that prevents WordPress from running as expected. The causes it lists include running an incompatible PHP version. You just changed PHP, so treat that as your main suspect until a log says otherwise.
Check the admin inbox for the recovery link
The error message itself tells you where to look first: "Please check your site admin email inbox for instructions." WordPress's guide also says to check your email first, to see if WordPress has sent you any details about the error. That email can include a secret link to WordPress's recovery mode.
Recovery mode works by placing a cookie on the client you open the link in. For that client, the plugins and themes causing the fatal error are paused. That lets you get into the dashboard and decide what to do about the problem. The pause is for that client only, so treat it as your way in, not the fix.
If the paused plugin isn't one your site needs to run right now, deactivate it and check the front end. If it is something you need, like your shop or booking plugin, skip to the next section and switch PHP back instead.
No email? Check spam, then stop waiting. WordPress's core post on recovery mode says environments can disable the fatal error handler and recovery mode altogether. If yours did, don't wait for a link.
Switch PHP back to the version that worked
WordPress's PHP update page gives a plain fallback: if something goes wrong, contact your host and ask them to restore the previous version of PHP you had running. If you switched it yourself in the hosting panel, go back to that same setting and pick the version you had before.
This doesn't fix the broken code. It only buys you time to find it without a dead site. Update, fix or replace the plugin or theme that broke before you switch again.
Get into the dashboard when wp-admin is broken too
Sometimes the admin screens show the critical error too and you have no recovery link. Then use FTP or your host's file manager and rename the wp-content/plugins folder. WordPress's guide says renaming it does this: "This will deactivate all of your Plugins."
If the site loads after the rename, look at your plugins first. Rename the folder back to plugins, log in, and turn them on one at a time. The guide's advice is to try deactivating all of your plugins and then reactivating them one by one. Reload the front end after each one. The plugin that brings the error back is your culprit.
If plugins aren't it, try the theme. The guide says to rename the folder for the active theme, or to activate a default WordPress theme. It names Twenty Twenty-One as its example. If the site comes back on the default theme, your theme is the one to look at.
Read the debug log to find what failed
Turning things off one at a time works, but it's slow. WordPress's guide says the next step is to enable debug mode in wp-config.php and then review the error logs located in wp-content/debug.log to find out what specifically went wrong. The debugging docs explain that WP_DEBUG_LOG causes all errors to also be saved to a debug.log log file in the content directory.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );Placement matters, and it's easy to miss. The guide says "You must insert this BEFORE" the stop-editing comment in wp-config.php. For WP_DEBUG_DISPLAY, the docs say setting it to false will hide all errors. With WP_DEBUG_LOG on, you read them in debug.log instead.
Here's the catch: the same docs say it is not recommended to use WP_DEBUG or the other debug tools on live sites, and to use them in a local development or staging environment. So the clean order is: switch the live site back to the old PHP, make a staging copy, set the copy to the new PHP version, and read the log there.
In the log, look at the newest fatal error. If it points into a plugin or theme folder, that folder is your suspect. That beats guessing, and it gives you something concrete to send the plugin's developer.
When it isn't a plugin or theme
The PHP switch is the main suspect, but not the only one. WordPress's guide lists hitting the memory limit and corrupted WordPress files among the common causes, next to plugin conflicts and theme compatibility issues. If the log points to memory, the guide's fix is to increase your memory limit in wp-config.php. If the log points into WordPress's own files rather than a plugin or theme, look at those files next.
Fix the cause before you switch PHP again
- Update everything first. WordPress's PHP page says to update everything from the Updates page before you update PHP.
- Make a backup. The same page says a backup will let you revert your site to how it is right now in the event anything goes wrong.
- Ask the developer. If you're unsure whether a plugin or theme works with newer versions of PHP, the page says to ask its developer. Send them the error line from your log.
- Scan the code for the version you're moving to. We make a free plugin, Bright Labs Compatibility Scanner for PHP, that reads every installed plugin and theme and lists each file and line that uses something removed or deprecated in the PHP version you pick, for PHP 8.2 to 8.5. It runs inside WordPress with no shell access. A clean scan isn't a promise, because it reads code without running it.
- Test on staging first. If your hosting company offers a staging site, update PHP there first and test your site before updating your live site.
Sources
- WordPress guide to common errors and the critical error message
- WordPress core post on fatal error recovery mode
- WordPress page on updating your site's PHP version
- WordPress guide to debugging with WP_DEBUG and debug.log
Questions
Will switching PHP back fix my WordPress site for good?
It puts the site back on the PHP version it ran on before, which is the fallback WordPress's own PHP page gives: ask your host to restore the previous version. Treat it as a way back online, not a fix. Update, fix or replace that plugin or theme before you switch again.
Why didn't I get the recovery mode email?
Check spam first. WordPress's core post on recovery mode also says environments can disable the fatal error handler and recovery mode altogether. If yours did, don't wait for a link: rename the plugins folder over FTP or switch PHP back.
Is it safe to turn on WP_DEBUG on my live site?
WordPress's debugging docs say it is not recommended to use WP_DEBUG or the other debug tools on live sites. Use a staging copy on the new PHP version instead. Keep WP_DEBUG_DISPLAY set to false, which the docs say hides all errors, and read debug.log.
Does a clean compatibility scan mean my site will work on the new PHP version?
No. Our scanner reads code without running it, so it can miss problems in code that is built at runtime, and it can flag code that never runs. Treat a clean result as a good sign, and still test on a staging copy before a big upgrade.
Related
- Which plugin is causing the PHP deprecated warnings in your WordPress log? How to find it
- PHP 8.2 end of life: what it means for your WordPress site and what to do before it
- "Implicitly marking parameter as nullable is deprecated" in WordPress: what it means and the fix
- Site Health says your PHP is outdated: what the WordPress warning means and how to fix it safely