Blog

How to fix ‘There has been a critical error on this website’

Ink sketch of a browser window with wavy lines on screen and a small green wrench resting against it.

“There has been a critical error on this website” means PHP hit a fatal error while loading your site, and WordPress caught it instead of showing a blank page. The cause is almost always a plugin, a theme, or PHP running out of memory. To fix it, find the file named in the error, then turn off that plugin or theme. If you cannot reach wp-admin, rename the plugin’s folder in your hosting file manager. WordPress turns off a plugin whose folder has gone, and the site comes back.

This guide explains what each version of the message means, why the recovery email often never arrives, how to read the error yourself, and how to fix the memory error that brings up the same screen.

What does “there has been a critical error on this website” mean?

WordPress has a fatal error handler that runs when PHP stops on a serious error, such as a call to a function that does not exist or a script that runs out of memory. Instead of a blank page, it shows a short message and sends the page with HTTP status 500. That is why server logs and uptime checkers report a 500 error at the same moment visitors see the message.

We read the handler in the WordPress source, version 7.1.4, in the file class-wp-fatal-error-handler.php. It has four versions of the message, and which one you see tells you something:

  • “There has been a critical error on this website.” The plain version. Visitors see it on the front of the site.
  • “… Please check your site admin email inbox for instructions.” Shown on the login page and in wp-admin of a single site. WordPress has tried to email you a recovery link.
  • “… Please reach out to your site administrator.” The same case on a multisite network, where the network admin handles it.
  • “… putting it in recovery mode. Please check the Themes and Plugins screens for more details.” You are already logged in through a recovery link, and WordPress has paused the plugin or theme that failed.

Every version ends with a link to WordPress.org’s troubleshooting page. The message itself never names the plugin. For that you need the recovery email or the error log.

Why does wp-admin show a different message from the homepage?

We tested this on a throwaway copy of WordPress 7.1.4 with PHP 8.3. We added a small plugin that calls a function that does not exist, then loaded three pages:

  • The homepage showed the plain message.
  • The login page and wp-admin showed “Please check your site admin email inbox for instructions.”
  • All three pages returned HTTP status 500.

The difference comes from what WordPress calls protected endpoints. In the source, the login page and wp-admin are protected, and the front of the site is not. WordPress only tries to send the recovery email when the error happens on a protected page. A visitor who sees the error on your homepage does not trigger any email. The email goes out the first time someone opens the login page or wp-admin while the error is still there.

Where is the recovery mode email, and why did it not arrive?

The email goes to the site’s administration email address, set under Settings, General. A developer can send it somewhere else by defining RECOVERY_MODE_EMAIL in wp-config.php. The subject line is “[Your site name] Your Site is Experiencing a Technical Issue”. In our test it named the plugin, the file and line of the error, the WordPress and PHP versions, and a recovery link that expires in one day.

If it never came, check these in order:

  1. Nobody has opened wp-admin or the login page yet. As above, front-end errors do not send it.
  2. It went to an old address. The administration email is often an address from the day the site was built.
  3. Your site cannot send email. WordPress sends it through the same mail function as order and password emails. If those do not arrive either, our guide on why WooCommerce order emails don’t arrive covers the fixes.
  4. One was already sent today. WordPress sends at most one recovery email a day. In the source, it saves the “last sent” time before it tries to send. So if sending fails, it still waits a full day before it tries again.

We saw point 4 happen. Our test server had no mail program, so the email failed. The login page still told us to check our inbox, and WordPress had already recorded the attempt. Do not wait for the email. The error log gives you the same details.

How do you use recovery mode?

If the email did arrive, recovery mode is the quickest fix:

  1. Click the link in the email. WordPress shows “Recovery Mode Initialized. Please log in to continue.”
  2. Log in with your usual username and password. If you have lost the password, our guide on resetting your password explains the options.
  3. wp-admin opens with a notice that you are in recovery mode. On the Plugins screen, the plugin that failed sits under “Paused”, with the error message under its name.
  4. Click Deactivate on that plugin, or switch themes if a theme failed.
  5. Click “Exit Recovery Mode” at the top of the screen.

Step 4 matters. Recovery mode pauses the plugin only for your own login session. In our test, while we were in recovery mode, a logged-out visitor still got the critical error and a 500 status on the homepage. The site is only fixed for everyone once you deactivate, update or replace the plugin.

How do you fix it without wp-admin or the email?

Use your hosting control panel’s file manager, or FTP:

  1. Open the folder wp-content/plugins.
  2. Rename the folder of the plugin you suspect, for example from contact-form to contact-form.off.
  3. Reload the site.

In our test, renaming the broken plugin’s folder brought the homepage back with status 200. When we opened the Plugins screen, WordPress showed “The plugin broken-test/broken-test.php has been deactivated due to an error: Plugin file does not exist.” Rename the folder back afterwards if you want to reinstall or update the plugin. It stays deactivated until you turn it on again.

If you do not know which plugin it is, rename the whole plugins folder to plugins.off. That turns every plugin off. Once the site loads, rename it back and turn the plugins on one at a time until the error returns.

If the error points at a theme, rename that theme’s folder inside wp-content/themes. In the source, when you next open Appearance, Themes, WordPress sees the active theme is missing and switches to its default theme if that is installed. Keep at least one default WordPress theme installed for this reason.

How do you find which plugin caused the error?

Read the error itself. You can turn on WordPress’s own error log by adding these lines to wp-config.php, above the line that says “That’s all, stop editing!”:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

WordPress.org’s guide to debugging in WordPress explains each one. The third line keeps errors off the screen, so visitors do not see file paths. Load the broken page once, then open wp-content/debug.log. In our test the log held a line starting “PHP Fatal error: Uncaught Error: Call to undefined function”, followed by the full path of the plugin file and the line number.

The path is the answer. A path containing wp-content/plugins/some-plugin/ means that plugin. A path containing wp-content/themes/ means the theme. Once the site works again, set WP_DEBUG back to false and delete debug.log, because anyone who guesses its address can read it.

Your host may also keep a PHP error log you can open from the control panel. On our test server, the same fatal error line appeared in the server’s log without any change to wp-config.php.

What if the error says “Allowed memory size exhausted”?

Then PHP ran out of memory, and WordPress shows the same critical error screen. The log line reads “Allowed memory size of X bytes exhausted”. The number tells you the limit in bytes. 41943040 bytes is 40 MB.

WordPress has its own memory setting, WP_MEMORY_LIMIT. In the WordPress source, its default is 40M on a single site and 64M on multisite. People often read that as WordPress limiting itself to 40 MB, which is not what the code does. WordPress only ever raises PHP’s limit. It never lowers it. We tested this with a plugin that asks for about 60 MB of memory:

  • PHP limit 128M (PHP’s own default), no setting in wp-config.php. The page loaded. The 40M default did nothing, because PHP already allowed more.
  • PHP limit 32M, no setting. WordPress raised the limit to 40M, which was still too little. Critical error, and the log said “Allowed memory size of 41943040 bytes exhausted”.
  • PHP limit 32M, WP_MEMORY_LIMIT set to 128M. The page loaded.
  • PHP limit 32M, WP_MEMORY_LIMIT set to 24M. The limit stayed at 32M. A lower value is ignored.

So the fix is one line in wp-config.php, above “That’s all, stop editing!”:

define( 'WP_MEMORY_LIMIT', '256M' );

WordPress.org’s page on editing wp-config.php describes this setting and WP_MAX_MEMORY_LIMIT, which applies to heavier admin tasks and defaults to 256M in the source.

There is one case where this line does nothing. If your host has locked PHP’s memory limit so scripts cannot change it, the source makes WordPress use the current limit as it is. Then raise memory_limit in your hosting control panel’s PHP settings, or ask your host. If a single plugin needs far more memory than the rest of the site, look at that plugin too. More memory hides the problem but does not fix it.

Why did the critical error start after a PHP update?

A plugin or theme can use PHP features that a newer PHP version has removed or changed. It works on the old version and fails on the new one. The fix order is:

  1. Switch PHP back to the previous version in your hosting control panel, so the site works again.
  2. Read the error log to see which plugin or theme failed.
  3. Update it. If there is no update that supports the new PHP version, replace it.
  4. Switch PHP forward again.

The same order works after a WordPress or plugin update. Updating one plugin at a time, on a staging copy if your hosting has one, tells you straight away which update caused the error.

Is a critical error the same as a white screen or a 500 error?

Often they are the same problem shown in different ways. The fatal error handler was added in WordPress 5.2, according to the version notes in its source. Without it, a fatal error leaves a blank page. We checked this by turning the handler off with WP_DISABLE_FATAL_ERROR_HANDLER on our test site. The same broken plugin then gave a 500 status and a completely empty page, which is the “white screen of death”. The fix is the same either way, and it starts with the error log.

A 500 error can also come from the web server before WordPress runs at all. When we added an invalid line to the test site’s .htaccess file, the server answered with its own “500 Internal Server Error” page and no WordPress message. If you see that plain server page, check .htaccess and the server’s error log first.

How do you stop it from happening again?

  • Keep the site’s administration email current, and make sure your site can send email.
  • Update plugins one at a time, and test on a staging copy first if you have one.
  • Remove plugins you do not use. WordPress does not load a plugin that is turned off, but one that is turned on and forgotten still runs on every page.
  • Keep a recent backup, so you can roll back if a fix takes longer than expected.
  • If you find plugin or theme files you did not install, treat it as a possible hack and follow our guide for a hacked WordPress site.

WordPress.org’s troubleshooting FAQ covers other errors that look similar. If you are choosing hosting for a new site, our WordPress hosting page explains what the plans include.

Frequently asked questions

Can visitors see which plugin broke my site?

No. The critical error message does not name the plugin or show file paths. Only the recovery email and the error log show those details, and only you can read them.

How do I fix a critical error if I can’t log in to wp-admin?

Rename the plugin’s folder inside wp-content/plugins using your hosting file manager or FTP. WordPress deactivates a plugin whose folder is missing. If you do not know which plugin it is, rename the whole plugins folder.

Why didn’t I get the recovery mode email?

WordPress only sends it when the error happens on the login page or in wp-admin, at most once a day, to the administration email address. If your site cannot send email, the attempt fails and WordPress still waits a day before trying again.

Does WordPress limit itself to 40 MB of memory?

No. 40M is the default for WP_MEMORY_LIMIT, but WordPress only uses it to raise PHP’s limit when PHP allows less. If PHP already allows more, nothing changes.

Will the critical error fix itself?

Not usually. The error comes back on every page load until the plugin, theme or setting that causes it changes. Recovery mode only hides it for your own login session.

Category:

Written by

Muhammad Dilawar

Muhammad Dilawar

Muhammad Dilawar is a WordPress developer and technical SEO specialist with over 12 years of experience building, optimizing and maintaining websites. He works with WordPress, WooCommerce, server optimization, DNS, SSL, Cloudflare, website security and performance, and is a Top Rated freelancer on Upwork with a 100% recommendation rate.

Hosting for your WordPress site

Yearly plans in rupees, with the same price at renewal. Free SSL and daily backups on every plan.