WordPress guides

Understanding WordPress errors and debugging your site

Understanding WordPress errors and debugging your site

White screen, “There has been a critical error on this website.”, a 500 error or a failed database connection: behind every WordPress message there is a precise cause, almost always written down in a log somewhere. This guide explains how to read the common errors, use recovery mode, turn on debugging without exposing your site, and which tools help you find the culprit in minutes.

The right reflex: find the real message

The message shown to visitors is deliberately vague: it must not reveal server paths. The real error is found, from easiest to hardest:

  1. in the recovery mode email, sent to the admin email address when a fatal error occurs;
  2. in your host’s PHP error logs (customer area, cPanel, Plesk);
  3. in the WordPress debug log, once it is turned on;
  4. in the browser console for JavaScript errors (block editor stuck, a button that no longer responds).

Before you start digging, ask yourself what changed: a plugin update, a new PHP version at your host, a theme edit. Nine times out of ten, that is where the cause lies.

The most common WordPress errors

What you seeLikely causeFirst action
Blank pageFatal PHP error, error display turned offRead the error log, deactivate the last plugin you changed
“There has been a critical error on this website.”Fatal error in a plugin or the themeFollow the link in the recovery email
500 errorInvalid .htaccess, server limit, PHP errorRename .htaccess, read the server log
404 on every page except the home pageRewrite rules lostSettings, Permalinks, Save Changes
“Error establishing a database connection”Wrong credentials in wp-config.php, MySQL server downCheck the credentials, contact your host
“Allowed memory size… exhausted”Not enough PHP memory or a memory-hungry pluginRaise WP_MEMORY_LIMIT, look for the leak
“Briefly unavailable for scheduled maintenance. Check back in a minute.”Interrupted update, leftover .maintenance fileDelete .maintenance, run the update again
Too many redirectsSite address in HTTP behind an HTTPS proxyCheck siteurl, home and HTTPS detection

Memory exhausted

By default WordPress asks for 40 MB of memory (64 MB on multisite) for the public site and up to 256 MB in the admin, without being able to go beyond the limit set by your host. You can raise the first one in wp-config.php with define( 'WP_MEMORY_LIMIT', '256M' );. If the error comes back with more memory, a plugin is looping: adding even more only delays the crash.

Stuck in maintenance mode

During an update, WordPress creates a .maintenance file in the root folder. It ignores the file on its own after ten minutes; if the message persists, delete the file, then clear the page cache, which may have stored the maintenance screen. Then run the interrupted update again, because the plugin concerned may be incomplete.

Recovery mode after a critical error

Since WordPress 5.2, a fatal error triggers recovery mode: WordPress sends the admin email address a message that names the plugin or theme at fault and contains a special login link. That link opens the admin with the faulty component paused for you alone, long enough to deactivate or update it. The link is only valid for a limited time.

The email never arrives? The admin address may be out of date, or the site may not be sending emails at all. You can set another address with the RECOVERY_MODE_EMAIL constant, or deactivate the plugin without going through the admin:

# Without loading the plugins or the theme that cause the error
wp plugin list --status=active --skip-plugins --skip-themes
wp plugin deactivate plugin-name --skip-plugins --skip-themes

# Without WP-CLI: rename the plugin folder over SFTP
# wp-content/plugins/plugin-name  becomes  plugin-name.off

Turn on debugging without exposing your site

Debug mode is set in wp-config.php, above the line “That’s all, stop editing! Happy publishing.”. On a live site, errors must be logged but never displayed, and the log must be written outside the public folder:

define( 'WP_DEBUG', true );
// Log outside the public folder (adapt the path to your hosting)
define( 'WP_DEBUG_LOG', '/home/account/logs/wp-errors.log' );
// Never display errors to visitors
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// Only for a JavaScript error in core: unminified scripts
// define( 'SCRIPT_DEBUG', true );

With WP_DEBUG_LOG set to true, the log is written to wp-content/debug.log, an address everyone knows and that bots probe constantly. This file contains server paths, plugin names and sometimes SQL queries or email addresses: never leave it publicly accessible in production. Prefer a path outside the public folder, block access to the file at server level, and once the problem is found, set WP_DEBUG back to false and delete the log. Our article on exposed sensitive files shows how to check this, and our wp-config.php guide covers the other settings.

How to isolate the culprit

Method for debugging a WordPress errorFive steps: read the real message in the recovery email or the log; reproduce the error on a staging site; isolate it by deactivating plugins and switching to a default theme; fix it with an update, a rollback to the previous version or a PHP version change; finally turn debugging off and delete the log.1. Read the real messagerecovery email, PHP log2. Reproduce away from productionstaging site, local copy3. Isolateplugins deactivated, default theme4. Fixupdate, previous version, PHP5. Close upWP_DEBUG set to false, log deletedOne change at a time, written down.Method for debugging a WordPress errorFive steps: read the real message in the recovery email or the log; reproduce the error on a staging site; isolate it by deactivating plugins and switching to a default theme; fix it with an update, a rollback to the previous version or a PHP version change; finally turn debugging off and delete the log.1Read the real messagerecovery email, PHP log2Reproduce away fromproductionstaging site, local copy3Isolateplugins deactivated, default theme4Fixupdate, previous version, PHP5Close upWP_DEBUG set to false, log deletedOne change at a time, written down.

To isolate without breaking the site for visitors, the Health Check & Troubleshooting plugin offers a “Troubleshooting Mode” that deactivates plugins and switches theme for your session only. On a staging site, you can simply deactivate everything and reactivate items one by one.

Diagnostic tools

  • Site Health (Tools): the Status tab flags known issues (old PHP, late scheduled events, blocked outgoing requests); the Info tab gives the full configuration, ready to copy for a support request.
  • Query Monitor: a free plugin that shows, to administrators only, the page’s PHP errors, slow or duplicate SQL queries, HTTP calls and the component responsible for each one. Deactivate it once the diagnosis is done.
  • WP-CLI: wp doctor is not included by default, but wp core verify-checksums, wp plugin list and --skip-plugins are enough in most cases.
  • Browser console (F12): JavaScript errors and failed requests (403, 500) when the editor or a form stops responding.

Errors caused by the PHP version

WordPress 7 requires at least PHP 7.4 and recommends PHP 8.3 or later. Switching to a new PHP version is the most common cause of critical errors “when nothing was touched”: the host changes the version, and an old plugin uses a function that has been removed. Today’s “Deprecated” warning becomes the fatal error of the next version.

  • Before switching versions, test on a staging site with the debug log turned on, and read the warnings.
  • If the site goes down after the switch, go back to the previous version in your hosting control panel while you update or replace the plugin at fault.
  • Do not stay on an end-of-life version for the sake of a single plugin: replace it. The timeline is in our article on end-of-life PHP versions.

Knowing what changed before the crash

The question “what changed?” is easier to answer with a record. WP Feint Pro keeps an administrator activity log (plugins activated, deactivated or updated, settings changed, with the author and the time), flags a modified core file through its integrity check, and sends you email alerts. It is not a debugging tool: it does not read PHP errors. But it often answers the first question of the diagnosis. The free version, for its part, removes WordPress traces from the page source, which does not replace protecting the debug.log file.

Who changed what, and when

Activity log, core integrity and alerts: WP Feint Pro from €59 excl. VAT per year for one site. Start with the free version.

Frequently asked questions

How do I fix “There has been a critical error on this website.”?

Open the recovery email sent to the admin email address, follow the link and deactivate or update the component it names. With no email, deactivate the plugin with WP-CLI using --skip-plugins or by renaming its folder over SFTP, then read the error log.

Where is the debug.log file?

By default in wp-content/debug.log when WP_DEBUG_LOG is true. Set a path outside the public folder instead, and delete the file once the diagnosis is finished.

Can I leave WP_DEBUG on in production?

Only with display turned off and a log outside the public folder, for the duration of a diagnosis. Normally, leave it at false: the log keeps growing, and a forgotten file becomes an information leak.

Why does my site show a 500 error with no message?

The error often comes from the server before WordPress even loads: an invalid rule in .htaccess, a resource limit, the PHP version. Rename .htaccess, read the server error log in your hosting control panel, and contact your host’s support if the log is empty.

Key takeaways

  • The real message is in the recovery email, your host’s log or the debug log.
  • Critical error: recovery mode lets you deactivate the culprit without FTP.
  • In production: WP_DEBUG_DISPLAY set to false, log outside the public folder, then debugging turned off.
  • Never a publicly accessible debug.log.
  • Isolate one change at a time, on a staging site if possible.
  • PHP version change: test first, roll back if needed.

Sources

  • WordPress Developer: Debugging in WordPress (external link, opens in a new tab)
  • Make WordPress Core: Fatal Error Recovery Mode in 5.2 (external link, opens in a new tab)
  • WordPress.org: Requirements (external link, opens in a new tab)
  • WordPress.org: Query Monitor (external link, opens in a new tab)