How to enable WordPress debug mode, and what to do next
Turn on WordPress debug mode with three lines in wp-config.php, find debug.log, and learn what to do with what it shows you.
On this page
To turn on WordPress debug mode, add three lines to wp-config.php above the line that says "That's all, stop editing". WordPress will then write PHP errors to wp-content/debug.log without showing them to visitors.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );What does each debug setting do?
| Setting | What it does |
|---|---|
WP_DEBUG | Turns on error reporting for PHP errors, warnings, notices and deprecations. |
WP_DEBUG_LOG | Saves them to wp-content/debug.log. Give it a file path in place of true to save somewhere else. |
WP_DEBUG_DISPLAY | Shows errors on the page when true. Keep it false on a live site. |
SCRIPT_DEBUG | Loads the full, unminified versions of WordPress's own scripts and styles. |
SAVEQUERIES | Records every database query for the current page. It slows the site, so turn it off afterwards. |
Where is the WordPress debug log?
By default it is wp-content/debug.log. The file does not exist until the first error is written. If it never appears, either nothing has gone wrong yet or the web server cannot write to the wp-content folder.
Is it safe to turn on debug mode on a live site?
Yes, with two conditions. Keep WP_DEBUG_DISPLAY set to false, so visitors never see error text. And protect the log file, because by default anyone who types its address can open it. See Is debug.log public?
What do I do after debug mode is on?
This is where most guides stop. The log is only useful once you can read it.
- Reproduce the problem: load the page that breaks or runs slowly.
- Open
debug.logand go to the last lines. - Find the file path in the error. The folder name after
plugins/orthemes/tells you whose code it is. - Act on it: update, replace or report that plugin. See How to read the WordPress debug log.
What debug mode will not tell you
Debug mode records PHP errors. It does not record slow pages, slow database queries, slow calls to outside services, slow emails or scheduled jobs that overran. A site can be painfully slow with an empty debug log.
How Paul Bunyan helps
Paul Bunyan records errors and timings together. Errors are grouped and counted by plugin, and every request is timed, so the same screen shows you what broke and what was slow. No wp-config.php edit is needed.
