Skip to content
Troubleshooting

How to debug errors in WordPress

Turn on WP_DEBUG and the debug log safely, read the error, isolate a plugin or theme, and switch debugging off again so nothing leaks.

By WP24×7 engineers4 min readPublished March 1, 2021Updated November 29, 2026

At a glance

A white screen, a critical error message or a feature that silently does nothing share one first step: make WordPress tell you what went wrong. Turn on WP_DEBUG with logging and display off, read wp-content/debug.log, isolate the plugin or theme by deactivating one thing at a time, then switch debugging off and delete the log so nothing leaks.

Updated November 29, 2026 · For WordPress site owners and developers

  • For owners and developers facing a white screen, critical error or silent failure
  • Settings WP_DEBUG true, WP_DEBUG_LOG true, WP_DEBUG_DISPLAY false
  • Log location wp-content/debug.log, or a path outside the web root
  • Isolate deactivate all plugins, then one at a time; try a default theme
  • Safety back up or use staging; switch debugging off and delete the log afterwards
  • Recovery mode WordPress 5.2 and later may email an administrator a recovery link
  • Help emergency support or WordPress support

A white screen, a "critical error" message or a feature that silently does nothing all have the same first step: make WordPress tell you what went wrong, then change one thing at a time.

How do I turn on the debug log?

Edit wp-config.php over SFTP or your host's file manager. Add these lines above the comment that says to stop editing:

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

WP_DEBUG_LOG writes errors to wp-content/debug.log. WP_DEBUG_DISPLAY set to false keeps them off the page, so visitors never see a stack trace. If the constants are already defined, change the existing lines rather than adding duplicates.

Reproduce the problem, then open the log. The last lines are usually the cause. A fatal error names a file under wp-content/plugins/ or wp-content/themes/, which tells you who is responsible.

How do I read the error?

What the log saysWhat it usually means
Fatal error, with a pathThe plugin or theme in that path is the culprit or is missing a dependency
Allowed memory size exhaustedA script ran out of PHP memory; find what was running before raising the limit
Call to undefined functionA plugin needing another plugin, or a PHP version mismatch after an update
Database errorsCheck credentials in wp-config.php and that the database server is up

Since WordPress 5.2 a fatal error can also trigger recovery mode, which emails the administrator a special link to log in and deactivate the broken plugin or theme. Check that inbox first.

LevelMeaning
Fatal errorExecution stopped; the page is broken
WarningSomething went wrong but the page continued
Notice or deprecatedWorks today but uses something being retired; rarely the cause of a broken page

When a site fails, read from the bottom of the file for the newest fatal error first.

Read the newest fatal error first, then isolate the cause

How do I isolate the cause?

  1. Take a backup,

    or work on a staging copy.

  2. Deactivate all plugins

    If you cannot reach the dashboard, rename wp-content/plugins to plugins-off, or run wp plugin deactivate --all with WP-CLI.

  3. Reactivate one at a time

    until the problem returns, if it was gone.

  4. Switch to a default theme

    such as the newest Twenty-series theme, if it persists.

  5. Look at the host

    the PHP error log in the hosting panel, the PHP version and recent changes such as an update or a migration.

What if the problem is in the browser?

If the page loads but a button, slider or form is dead, the error is in JavaScript. Open developer tools, the Console tab, and reload. For slow or failing requests, check the Network tab. The Query Monitor plugin is useful on staging for slow queries and hooks.

How do I keep the log private?

On many setups wp-content/debug.log can be fetched by anyone who guesses the address, and it can contain file paths, plugin names and sometimes user data.

  • Keep the debugging window short: switch on, reproduce once, read, switch off.
  • Delete the file afterwards.
  • If your host allows, send the log outside the web root with a path, for example define( 'WP_DEBUG_LOG', '/home/youraccount/logs/wp-debug.log' );. The folder must exist and be writable by the web server, and the path is specific to your host.

When you are done set WP_DEBUG back to false or remove the lines, and delete `wp-content/debug.log`.

What other switches are useful?

ConstantUseCaution
SCRIPT_DEBUG trueLoads unminified core scripts and styles for readable console errorsTurn off afterwards
WP_DEBUG_DISPLAY false plus @ini_set( 'display_errors', 0 );Stops anything printing even when a plugin changes settingsNone
SAVEQUERIES trueRecords queries for Query MonitorSlows the site; staging only

A worked example

A contact page shows a blank area where the form should be. You switch the log on, reload and find a line saying a function from the form plugin is undefined and the call came from a file in your theme. A plugin update probably removed or renamed the function. The fix is to update the theme code, or roll the plugin back until the theme is fixed. Without the log you might have spent an hour reinstalling the form plugin and learned nothing.

What mistakes are common?

Still stuck?

If the site is down or a store cannot take orders, call for emergency support. For anything else, ask an engineer, and we will find the cause with you.

Need a second pair of eyes?

Send the last lines of your log.

FAQ

Questions people ask

12 answers. Can't find yours? Ask an engineer.

Where is the WordPress debug log?

With WP_DEBUG_LOG set to true, WordPress writes to wp-content/debug.log. Delete it when you finish, because it can be read by anyone who guesses the URL on many setups.

Link to this answer
Is it safe to leave WP_DEBUG on?

No. Turn it off when you are done. At minimum never display errors to visitors on a live site.

Link to this answer
What is the difference between WP_DEBUG_LOG and the host's PHP error log?

WP_DEBUG_LOG writes WordPress-level notices and errors to wp-content/debug.log. The host's PHP error log is kept outside WordPress and also catches errors that stop WordPress loading at all, so check both.

Link to this answer
Should I debug on the live site?

Prefer a staging copy. If you must debug live, keep display off, log only, reproduce the fault once, then switch it all off and delete the log.

Link to this answer
Why do my debug settings not work?

The define lines must go above the comment that says to stop editing in wp-config.php. If a constant is already defined, change the existing line instead of adding a duplicate.

Link to this answer
What does a fatal error line tell me?

It names a file under wp-content/plugins or wp-content/themes, which tells you which plugin or theme is the culprit or is missing a dependency.

Link to this answer
What does Allowed memory size exhausted mean?

A script ran out of PHP memory. Find what was running before simply raising the limit, since a bigger limit can hide the real cause.

Link to this answer
How do I deactivate plugins if I cannot reach the dashboard?

Rename the wp-content/plugins folder to plugins-off, and WordPress treats them all as deactivated. With WP-CLI, run wp plugin deactivate --all.

Link to this answer
What is recovery mode?

Since WordPress 5.2 a fatal error can trigger recovery mode, which emails the site administrator a special link to log in and deactivate the broken plugin or theme. Check that inbox first.

Link to this answer
How do I keep the debug log from being public?

Keep the debugging window short, delete the file afterwards and, if your host allows, give WP_DEBUG_LOG a file path outside the web root. The folder must exist and be writable by the web server.

Link to this answer
What is the difference between a fatal error, a warning and a notice?

A fatal error stops execution and breaks the page, a warning means something went wrong but the page continued, and a notice or deprecated message flags code that works today but is being retired. Read from the bottom of the file for the newest fatal error first.

Link to this answer
What if the page loads but a button or slider is dead?

The error is in JavaScript. Open developer tools, the Console tab, and reload. For slow or failing requests check the Network tab.

Link to this answer

Keep reading

Want an engineer on it?

Tell us what is wrong in plain words. A person reads it, today.