How to turn on WordPress debugging and read the debug log
How to switch on WP_DEBUG safely, find wp-content/debug.log, read a PHP error line, tell fatal errors from harmless notices and switch debugging off again afterwards.
When WordPress breaks, the page you see rarely says why. "There has been a critical error", a blank white screen, a 500 error or an editor that won't save all hide the real message. WordPress's debug log, switched on with WP_DEBUG, records that message, usually along with the exact plugin, theme or file responsible.
Turning it on means adding a few lines to wp-config.php, reproducing the problem and then reading a text file. This guide covers each step, how to make sense of what you find and how to switch it all off again, which matters as much as switching it on.
Open wp-config.php
wp-config.php holds your site's main settings. It's usually in the same folder as the wp-admin, wp-content and wp-includes folders, often called public_html, www or htdocs on shared hosting. WordPress also looks one folder higher, so if it isn't next to those folders, check the folder above.1
Connect with SFTP or your hosting control panel's file manager, download a copy of the file to keep safe, then open it for editing. Some hosts have a "debug mode" switch in their control panel that does the same job without editing anything, so it's worth checking your host's help pages first.
Add the debug settings
Look for an existing line that reads define( 'WP_DEBUG', false );. Most sites have one, because it's part of the standard file WordPress ships with.2 Replace that line with the four lines below. If there isn't one, add them just above the comment that reads /* That's all, stop editing! Happy publishing. */ (older sites say "Happy blogging").3
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Replacing the old line matters. PHP only uses the first definition of a setting like WP_DEBUG,4 so if define( 'WP_DEBUG', false ); is still further up the file, debugging stays off and the log stays empty.
Here's what each line does:
WP_DEBUGswitches debug mode on. WordPress then reports every PHP error, warning and notice rather than only the serious ones.5WP_DEBUG_LOGwrites those messages to a file calleddebug.login yourwp-contentfolder.3WP_DEBUG_DISPLAYset tofalsestops the messages appearing on the page itself, so visitors don't see them.3- The last line tells PHP not to display errors either, as a belt-and-braces measure.
Type true and false without quote marks. With quotes, 'false' counts as text, and WordPress treats it as switched on.3
Save the file and upload it, replacing the original. If the site goes blank or shows a new error straight away, you've probably mistyped something. Put your saved copy back and try again.
Repeat the problem
The log only records errors that happen after you've switched it on. Go back and do whatever caused the problem: reload the page with the critical error, try saving the post again, place a test order or run the update that failed.
Errors in things that happen behind the scenes, such as saving in the block editor, scheduled tasks and checkout requests, are logged too, even though you never see them on screen.3
If the problem only shows up for visitors, reload the page in a private browser window while you're logged out. If your site uses page caching, clear the cache first, otherwise the server may send a saved copy of the page without running any PHP code at all. Our guide to a site showing old content explains where caches hide.
Open debug.log
Go to the wp-content folder and download debug.log. Open it in any text editor (Notepad, TextEdit or similar). The file only appears once something has been logged, so if it isn't there yet, nothing has gone wrong since you switched debugging on, or one of the problems under why the log might be empty applies.
New entries are added at the bottom, so start there and work upwards. Each line begins with a date and time in square brackets. These times are in UTC (the same as GMT), because WordPress sets PHP's clock to UTC,6 so during British Summer Time they'll be an hour behind the clock on your wall.
If the file is huge, don't try to read it all. Search for "Fatal error" and look at the most recent few.
Read the error line
Here's a typical fatal error, with a made-up plugin name:
[19-Nov-2026 10:42:13 UTC] PHP Fatal error: Uncaught Error: Call to undefined function example_get_price() in /home/user/public_html/wp-content/plugins/example-shop-addon/includes/cart.php:58
Stack trace:
#0 /home/user/public_html/wp-includes/class-wp-hook.php(341): example_cart_totals('')
#1 /home/user/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters('', Array)
...
Break it into parts:
- The time tells you whether this error lines up with when you saw the problem.
- The type ("Fatal error") tells you how serious it is. The table below explains the common types.
- The message ("Call to undefined function example_get_price()") says what went wrong. Copying it into a search engine, with the plugin name, often turns up a support thread or a fixed version.
- The file path says where it happened. The folder name straight after
wp-content/plugins/orwp-content/themes/is the plugin or theme involved, hereexample-shop-addon. The number after the colon is the line in that file. - The stack trace lists the steps that led to the error, most recent first. If the main path points into
wp-includesorwp-admin(WordPress's own files), look down the stack trace for the first line mentioningwp-content/plugins/orwp-content/themes/. WordPress itself is rarely the cause; it's usually being handed something it can't use.
The plugin named in the path is the best place to start, but it isn't always the one at fault. A plugin can fail because another plugin, your theme or your PHP version changed underneath it. Deactivating plugins one at a time, as covered in our critical error guide, confirms which one is really responsible.
Decide which messages matter
With debugging on, WordPress logs far more than the error you're looking for.5 On a busy site with older plugins, most of the log can be harmless housekeeping messages. This is roughly how to sort them:7
| Line starts with | What it means | What to do |
|---|---|---|
| PHP Fatal error | Code hit a problem it couldn't recover from and the page stopped loading | This is usually the error behind a crash. Start here |
| PHP Parse error | A file contains code PHP can't read, often from a recent edit or a half-finished upload | Undo the recent edit or re-upload the plugin or theme |
| WordPress database error | A database query failed8 | Look into it if it repeats, especially if it names a missing table |
| PHP Warning | Something went wrong but the page carried on | Worth a look if it mentions the feature that's misbehaving |
| PHP Notice | A minor problem in the code | Usually safe to leave. Mention it to the plugin's developer |
| PHP Deprecated | Code uses something that a future version of PHP or WordPress will remove | Not urgent, but a sign that updates are needed before your next PHP upgrade |
A few fatal errors come up again and again:
- "Allowed memory size of ... bytes exhausted" means PHP ran out of memory. Our guide to the memory exhausted error covers raising the limit and finding what's using it.
- "Maximum execution time of 30 seconds exceeded" means PHP itself spent that long working on one request, usually a big import, a backup, image processing or a plugin stuck in a loop. On Linux hosting, time spent waiting for the database or another site doesn't count,9 so a slow external service usually hits a different timeout first. Our guide to the maximum execution time error covers finding the cause, and our guide to 502, 503 and 504 errors covers the other timeouts.
- "Call to undefined function", "Uncaught TypeError" or "Class ... not found" straight after an update usually means a plugin, theme and WordPress version don't match, or an update only half finished. Our guide to a site broken by an update covers rolling back, and our guide to clearing the update lock covers rerunning a WordPress update that was cut off.
- "Cannot redeclare" usually means the same code is being loaded twice, for example the same snippet added to both
functions.phpand a snippets plugin, or two copies of a plugin installed.
Check why the log might be empty
If you've repeated the problem and debug.log still doesn't exist, or doesn't mention it, one of these is the likely reason:
- The old setting is still there. Search
wp-config.phpfor every mention ofWP_DEBUG. If an earlier line sets it tofalse, that one wins. - The page came from a cache. Clear your caching plugin, your host's cache and any service like Cloudflare, then try again.
- The error happens before WordPress starts. Mistakes in
wp-config.phpitself, faulty.htaccessrules and server problems happen too early for WordPress's log to catch. They go to the server's own PHP error log instead. Our 500 error guide covers these. - The host handles logging differently. Some hosts send PHP errors to their own log location, or stop WordPress writing files in
wp-content. Check your hosting control panel for a PHP or error log, or ask your host where errors go. - It isn't a PHP error. Problems in the block editor, page builders and anything that happens in your browser can be JavaScript errors, which never reach the server. See other places to look.
Look in other places
The debug log isn't the only record of what went wrong:
- The recovery mode email. For fatal errors caused by a plugin or theme, WordPress emails the site administrator the error and a special login link. Our critical error guide explains how to use it.
- Your hosting control panel. Most hosts keep a PHP error log, and it catches errors WordPress can't, including ones from before WordPress loads. Your host's support team can also check the web server's logs.
- WooCommerce logs. On WooCommerce sites, go to WooCommerce→ Status→ Logs and look for logs with the source "fatal-errors". WooCommerce records fatal errors there even when debugging is switched off.10 Payment gateways often keep their own logs on the same screen.
- Query Monitor. This free plugin, used on over 200,000 sites, shows the PHP errors, database queries and slow components for each page you view, and only to logged-in administrators.11 It's handy when a problem only shows up on certain pages. Remove it when you've finished, like any plugin you aren't using.
- The browser console. For errors in the block editor or anything interactive on the page, press F12 (or Cmd+Option+I on a Mac) and open the Console tab. Red messages there are JavaScript errors. Our guide to the "not a valid JSON response" error shows how a PHP warning can break the editor too.
- Site Health. Tools→ Site Health→ Info doesn't list errors, but it lists your WordPress, PHP, theme and plugin versions. The Copy site info to clipboard button gives a developer or your host the background they need alongside the log. Our guide to the Site Health Info tab covers what the copy includes.
If you send your log to someone else, send only the relevant lines from around the time of the problem. Logs include server file paths and sometimes details from forms or orders, so don't post a whole log in a public forum.
Turn debugging off and delete the log
When you've found the error, change WP_DEBUG back to false (or put your saved copy of wp-config.php back), then delete wp-content/debug.log.
Don't leave it running. On many servers anyone who knows the address can open files in wp-content, and the log can reveal file paths, plugin names and other details useful to an attacker. WordPress's own Site Health screen flags this as a critical security issue ("Your site is set to log errors to a potentially public file") while logging is on.12 A log left running on a busy site can also grow very large and use up your hosting space.
If you need to keep logging for a while, for example to catch an error that only happens once a week, WP_DEBUG_LOG can take a file path instead of true.3 Pointing it at a folder outside your public website folder keeps the log out of reach:
define( 'WP_DEBUG_LOG', '/home/youraccount/logs/wp-errors.log' );
The right path depends on your hosting, so ask your host which folder to use and make sure the folder exists. Remember to switch it off and delete the file when you've finished.
Common questions
Is it safe to turn on WordPress debug mode on a live site?
Logging to a file for a short time, with errors hidden from visitors, is a common way to track down a problem on a live site. WordPress recommends using debug mode on staging copies where you can.3 Never leave errors displayed on screen on a live site, and switch logging off and delete the log as soon as you have what you need.
Will turning on debugging slow my site down?
Logging on its own usually makes little noticeable difference. A plugin that produces hundreds of warnings on every page can slow things down and fill the log quickly, though, and extra developer settings such as SAVEQUERIES add more overhead.3 That's one more reason to switch debugging off once you've found the error.
Why is my debug log full of "Deprecated" messages?
Newer PHP versions have retired older ways of writing code, and many plugins and themes still use them. Deprecated messages are warnings about the future, not the cause of today's problem, so search past them for "Fatal error". A log full of them is worth passing to the developers concerned, and worth checking before your host moves you to a newer PHP version.
Can I show errors on the page instead of in a file?
Yes, by setting WP_DEBUG_DISPLAY to true, but everyone who visits sees them too, and WordPress's critical error screen still hides fatal errors unless you also switch it off with WP_DISABLE_FATAL_ERROR_HANDLER.5 Only do this on a staging or local copy of your site. On a live site, stick to the log file.
Need help reading your error log?
If the log doesn't point anywhere obvious, or the fix means changing code, send it to my emergency WordPress support and I'll find and fix the problem. Many fixes are £50 all in, you'll get a fixed quote before I start and it's no fix, no fee. My maintenance plans keep an eye on errors before they turn into outages. Your host can also check the server's own logs for errors WordPress can't see.
wp-load.php, WordPress source code on GitHub. ↩
wp-config-sample.php, WordPress source code on GitHub. ↩
Debugging in WordPress, WordPress Advanced Administration Handbook. ↩ ↩ ↩ ↩ ↩ ↩ ↩ ↩
wp-config.php, WordPress Advanced Administration Handbook. ↩ ↩ ↩
wp-settings.php, WordPress source code on GitHub. ↩
Predefined error constants, PHP Manual. ↩
class-wpdb.php (print_error), WordPress source code on GitHub. ↩
set_time_limit, PHP Manual. ↩
class-woocommerce.php (log_errors), WooCommerce source code on GitHub. ↩
Query Monitor, WordPress.org Plugin Directory. ↩
class-wp-site-health.php (get_test_is_in_debug_mode), WordPress source code on GitHub. ↩