Skip to content

How to fix "There has been a critical error on this website" in WordPress

WordPress shows this message in place of any page that PHP could not finish. It is the same whatever failed. The real error is one line, kept in an email to the site's administrator, in the debug log and in the server's log. Find that line first. It says which fix you need.

By
WP Ministry
Published
Tested on
WordPress 7.1.3, PHP 8.3.35

In short

  • The message is the same for every fatal PHP error. The real error is one line that WordPress keeps off the page.
  • Nothing is lost. Your posts, pages, settings and uploads are untouched.
  • Open your login page. WordPress emails a recovery link only when the error shows there or in the dashboard.
  • The email, the debug log and the host's error log each hold the real error. One of them is enough.
  • What that line says decides the fix. It may be memory, time, a syntax error, or one plugin or theme to switch off.
  • Renaming one plugin's folder switches that plugin off without the dashboard, and keeps its settings.

"There has been a critical error on this website." is what WordPress shows in place of a page when PHP, the language it runs on, stops with an error it cannot recover from. WordPress has caught such errors since version 5.2, which worded the message "The site is experiencing technical difficulties." The sentence is the same whatever failed. The real error is one line of text, and WordPress keeps it off the page.

Nothing has been lost. Your posts, pages, settings and uploads are where they were. Find that one line and you know which fix applies.

What the message tells you

The wording depends on where you read it.

  • On a public page: the one sentence and a link, "Learn more about troubleshooting WordPress." The link leads to general troubleshooting questions, not to anything about your site.
  • On the login page or in the dashboard: the same sentence, then "Please check your site admin email inbox for instructions." Recovery mode is running, and it emails a link when the failing file belongs to a plugin or a theme.
  • On the login page, with no mention of email: WordPress failed before recovery mode had started, as it does when the failing file is a must-use plugin. No email is coming. Go to the second fix.

What the line says, and where the fix is

The line saysWhat happenedWhere the fix is
Allowed memory size of … bytes exhaustedThe page asked for more memory than PHP allows.How to fix "Allowed memory size exhausted"
Maximum execution time of … seconds exceededThe page ran for longer than PHP allows.How to fix "Maximum execution time exceeded"
PHP Parse error, or E_PARSE in the emailPHP could not read a file as code.How to fix "Parse error: syntax error, unexpected"
Call to undefined function … or Class "…" not foundThe code called something that is not there.The PHP version fix below, if it began when the PHP version changed. Otherwise switch off the plugin or theme in the path.
Cannot redeclare …Two files define a function under one name, which PHP does not allow. The line names both.Switch one of the two off, then see how to find and fix a plugin conflict.
Failed opening required …A file the code needs is missing, as an update that did not finish can leave it.A WordPress update went wrong: a runbook
Anything elseThe plugin or theme in the path failed.Switch it off, as below.

A path through wp-content/plugins/ followed by a folder name is that plugin, and one through wp-content/themes/ is that theme. If the path is inside wp-includes or wp-admin, read down the lines under Stack trace: for the first path through wp-content. That code made the call that failed.

Where it goes wrong

A page request passes through each of these in turn. This one comes from PHP, the language WordPress runs on.

  1. Browser
  2. DNS
  3. HTTPS
  4. CDN or firewall
  5. Web server
  6. PHP (this error comes from here)
  7. WordPress
  8. Database and files

What causes it

How to fix it

Find the error behind the message

  • Takes care
  • Low risk
  • About 15 minutes
  • Steps tested on WordPress 7.1.3

The real error is written down in up to three places. One is enough.

  • The email. Its "Error Details" section is the error.
  • The host's error log. PHP has a log of its own, set by the server. Look for it in your hosting panel, or ask the host what PHP reported at the time of the fault.
  • WordPress's debug log. If you have neither, switch it on as follows.
  1. Step 1: Turn the debug log on

    In wp-config.php, find the line define( 'WP_DEBUG', false ); and replace it with these three, above the line that says "stop editing". They write errors to a file and keep them off the page.

    wp-config.php
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
  2. Step 2: Load the page that shows the message

    Once is enough.

  3. Step 3: Read the newest fatal line

    Open wp-content/debug.log and find the newest line that begins "PHP Fatal error" or "PHP Parse error". Over SSH, from the folder that holds wp-config.php, this prints the last three:

    bash
    grep -E "PHP (Fatal|Parse) error" wp-content/debug.log | tail -n 3
  4. Step 4: Turn the debug log off

    Set WP_DEBUG back to false and delete debug.log. How to turn on WordPress debug mode covers the rest: reading a line part by part, and keeping the log out of public view.

You can also paste the line into the WordPress error message and debug.log decoder. It shows what each line means, which plugin or theme it points at, and what to do first. It reads the lines in your browser, and nothing is sent.

To undo it: Set WP_DEBUG back to false and delete debug.log.

Switch the failing plugin or theme off from outside

  • Takes care
  • Low risk
  • About 10 minutes
  • Steps tested on WordPress 7.1.3

This brings the site back while the plugin or theme is being fixed. A plugin switched off this way keeps its settings.

  1. Step 1: Rename the plugin's folder

    In your host's file manager or over SFTP, open wp-content/plugins and add -off to the name of the folder the error named. Over SSH, from the folder that holds wp-config.php:

    bash
    mv wp-content/plugins/plugin-folder-name wp-content/plugins/plugin-folder-name-off
  2. Step 2: Reload the site

    It loads without that plugin. WordPress skips an active plugin whose file is not where it expects it.

  3. Step 3: Log in and open the Plugins screen

    Do this before you rename the folder back. WordPress finds the plugin's file gone there and records the plugin as deactivated. Until then it is only missing: put the folder back sooner and the plugin runs again, fault and all.

With WP-CLI there is nothing to rename. The two extra options keep WP-CLI from loading the broken code while it runs:

bash
wp plugin deactivate plugin-folder-name --skip-plugins --skip-themes

If the path named the theme, activate another installed theme by its folder's name:

bash
wp theme activate other-theme-folder-name --skip-plugins --skip-themes

The guide to deactivating plugins when you are locked out has the full method: every plugin at once, a theme without WP-CLI, must-use plugins and the database.

To undo it: Rename the folder back, then activate the plugin on the Plugins screen.

Undo the last change

  • Takes care
  • Back up first
  • About 30 minutes

If the message appeared straight after a change, that change is the first suspect.

  1. Step 1: If it began with an update

    Follow the runbook for an update that went wrong. It switches the updated plugin off, then chooses between going back one version and restoring the backup.

  2. Step 2: If it began with code you pasted or a file you edited

    Take the new code out, or upload the file as it was. How to fix "Parse error: syntax error, unexpected" shows how while the dashboard is down.

Match the PHP version to the code

  • Takes care
  • Back up first
  • About 20 minutes

Suspect this when the PHP version has just changed at the host. A new PHP version can remove old features, and code that still uses one stops. Call to undefined function create_function() is an example: PHP 8.0 removed that function. Code written for a newer PHP can fail on an older one, too.

  1. Step 1: Find the PHP version the site runs

    The recovery email gives it, on a line that begins "PHP version". Otherwise look in your hosting panel, where the version is set.

  2. Step 2: Find the version the code needs

    A plugin can state the lowest PHP version it supports on a Requires PHP line at the top of its main file.

  3. Step 3: Update the plugin or theme first

    A version written for your PHP may already be out. Once the plugin is deactivated and its folder has its own name again, update it from the dashboard.

  4. Step 4: Or change the PHP version for now

    Take a backup. Then set the version in your hosting panel to the one the site last worked on, or ask your host to. Treat that as temporary. The WordPress and PHP end-of-life checker shows whether your PHP and WordPress versions still get security fixes, and until when.

To undo it: Set the PHP version back in your hosting panel.

When to get help

Stop when the line in the log points at WordPress's own files and not at a plugin or the theme, when the site still fails with every plugin off and a default theme active, or when you can reach neither the files nor a log. On a store, stop sooner. Orders are being lost while you test.

Common questions

Why does the message not say what went wrong?

WordPress shows visitors one sentence for every fatal error. The details go to the administrator by email and to the error log. PHP's manual advises the same for any live site: log errors, do not display them.

Is this the same as the white screen of death?

It is the same failure, a fatal PHP error. A public page can still come out blank or cut off partway, because there WordPress shows the message only if nothing of the page had been sent when the error struck. How to fix the WordPress white screen of death starts from that blank page.

The message shows on one page only. Is that the same thing?

Yes. Each page runs different code, so a fault in one plugin's feature shows only where that feature runs. Turn the debug log on, load that page, and read the line it writes.

More on this subject

Would you rather we fixed it?

Emergency Fix is $99. Site down or checkout broken. Goes to the front of the queue. No fix, no fee. 30-day warranty. It starts with a free diagnosis.