A client's WordPress site says "There has been a critical error"
A plugin, a theme or the site's own code stopped with a fatal PHP error, and WordPress put up this message instead of the page. It hides the details from visitors on purpose. Here is where they went, and the order we would work in.
1. What the message means
Visitors see "There has been a critical error on this website." and a link to WordPress's troubleshooting help. On the login and admin pages it adds "Please check your site admin email inbox for instructions." The page answers with HTTP 500, a server error. WordPress has shown its own error screen for fatal errors since version 5.2.
It usually follows a change: a plugin or theme update, a new plugin, a PHP version change by the host, or a page that needs more memory than the server allows.
2. Find the email WordPress sent
When a plugin or theme causes the error on an admin or login page, WordPress emails the site's administration email address. The subject is "[Site name] Your Site is Experiencing a Technical Issue". It names the plugin or theme, the file and line, and the error message, and it carries a recovery mode link: log in through it and WordPress pauses the broken plugin or theme for you, so the dashboard works while you fix it.
- It probably went to the client. It goes to the address under Settings, then General, Administration Email Address, which is often the client's, not yours. Ask them to look, including in spam.
- It is sent at most once a day. If one went out in the last 24 hours, no new one is sent. The link in it works for a day.
- It may not exist. No email is sent when the error only happens on public pages, when it comes from the site's own code or a must-use plugin, on a multisite network, or when the server cannot send mail. If the error only happens on public pages, logging in at
/wp-adminonce may trigger it there and send the email. Otherwise, go to step 3.
3. No email? Turn on the error log
Open wp-config.php in the site's main folder, over SFTP or the host's file manager, and add these lines above the one that says "That's all, stop editing!":
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );If those names are already defined further up, change them there instead of adding them twice. Load the broken page once, then open wp-content/debug.log. The line with "PHP Fatal error" in it names the file, and the file's folder names the plugin or theme. The third line keeps the details off the screen, so visitors never see them. Set WP_DEBUG back to false when you are done, and delete the log: it sits at a well-known address that anyone can open.
4. Switch the cause off
- A plugin. In recovery mode, deactivate it from the Plugins screen. Without the dashboard, rename its folder in
wp-content/plugins, for example toplugin-name-off. WordPress cannot load it, and the site usually comes back. - The theme. Rename its folder in
wp-content/themes, then open Appearance, then Themes in the dashboard. WordPress switches to one of its own Twenty-something themes, if one is installed. Until you open that screen, visitors may see a blank page. The site will look different until you fix the theme, but it will load. - The host changed the PHP version. An old plugin can fail on a newer PHP. Most hosting panels let you switch back for now; then update or replace the plugin.
- "Allowed memory size exhausted". A page needed more memory than PHP allows. Raise the limit in the hosting panel, or find the plugin that needs that much.
With SSH and WP-CLI, one command switches a plugin off without loading the broken code: wp plugin deactivate plugin-name --skip-plugins --skip-themes, where plugin-name is the plugin's folder name.
5. Check the fix
Ask from a terminal rather than a browser that may show an old copy. This follows any redirects and prints the code the page finally answers with:
curl -sL -o /dev/null -w "%{http_code}\n" https://example.comOn Windows, type curl.exe and use NUL instead of /dev/null. It should print 200, not 500. Then load a few real pages in a private window, including the page named in WordPress's email if there was one, because a broken plugin can take down one page, such as the checkout, and leave the home page working.
6. Make sure the next email reaches you
WordPress lets wp-config.php choose where the recovery email goes, without changing the client's administration email:
define( 'RECOVERY_MODE_EMAIL', 'you@example.com' );Then tell the client what happened. For example:
The website showed an error message for a while because a plugin update did not work with the rest of the site. I have switched it off, checked the main pages are loading normally again, and will put a working version back.
7. Next time, hear about it first
WordPress's email comes at most once a day, only for a plugin or theme, only once the error reaches an admin or login page, and often to the client. Bionic Uptime reads the status code on every check, and the critical error page's HTTP 500 is a failed check. When both of our locations, on two different companies' networks, and a retry agree within 45 seconds, it is confirmed as an outage and each person on that website's alert list gets one email. For this error it says "Both checking locations received a server error (HTTP 500)." See the exact outage email.
Two cases a plain check cannot see. If the error happens after the page has started sending, WordPress shows no error screen: the page just stops partway, with a normal 200 code and often no message at all. Turn on Also check what the page says when you add the website, choose Must say, and enter a phrase from near the bottom of the page, such as text in the footer. A page that stops before it fails the check. The check reads the first 256 KB of the page, and the form tests your phrase against the live page before it saves it. And an error on one page, such as the checkout, leaves the home page working: add that page's address too, and each address counts as one of your websites. More on monitoring WordPress sites.
3 websites are free, forever, with no card. Looking after several client sites?