# WordPress Debug Mode: How to Enable WP_DEBUG and Read the Debug Log

> Source: https://mykavo.app/blog/wordpress-debug-mode  
> Author: Dakshesh  
> Published: 2026-10-01  
> Updated: 2026-11-23  
> Publisher: MyKavo (https://mykavo.app)  

## Summary

To enable WordPress debug mode, edit wp-config.php and set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false. Errors are then saved to wp-content/debug.log instead of shown to visitors. Read the log to find the plugin or theme at fault, then set WP_DEBUG back to false.

## Key takeaways

- WP_DEBUG is the master switch; WP_DEBUG_LOG and WP_DEBUG_DISPLAY control where errors go.
- On live sites, log errors and hide them from visitors with WP_DEBUG_DISPLAY false.
- debug.log lives in wp-content by default; move it outside the web root or block access.
- The file path in each log entry tells you which plugin or theme caused the error.
- Turn debugging off and delete debug.log as soon as you have found the problem.

WordPress debug mode turns hidden PHP errors into messages you can read, so you can find out why a page is blank, a plugin is crashing or your site shows "There has been a critical error on this website." You switch it on with a few lines in `wp-config.php`, and the safest setup writes errors to a log file instead of showing them to visitors.

This guide covers every debugging constant (WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY, SCRIPT_DEBUG and SAVEQUERIES), where `debug.log` lives and how to move it, how to keep the log private, how to read it, and how Query Monitor and recovery mode help. It ends with how to turn debugging off again, which is the step people forget.

> **Debugging a site that broke after an update?** The free [MyKavo WordPress plugin](https://mykavo.app/wordpress-plugin) checks your pages after every plugin, theme and core update and names the update when something broke. [Start monitoring free](https://mykavo.app/signup).

## Quick answer: how to enable WordPress debug mode

1. **Back up `wp-config.php`**, then open it via SFTP, your host's file manager or SSH.
2. **Find the line** `define( 'WP_DEBUG', false );` (or add it if it's missing).
3. **Replace it with the debug block below**, above the line that says "That's all, stop editing!"
4. **Reload the broken page**, then open `wp-content/debug.log` to read the errors.
5. **Fix the cause** (often a plugin, theme or PHP version issue).
6. **Turn debugging off** by setting `WP_DEBUG` back to `false` and deleting `debug.log`.

```php
// Enable WordPress debug mode, log errors, hide them from visitors
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
```

This is the recommended setup for a live site: errors go to the log, not to the screen.

## What WordPress debug mode does

By default WordPress hides PHP errors, warnings and notices. That keeps visitors from seeing technical messages, but it also means a broken page gives you nothing to go on.

**WP_DEBUG** is the master switch. When it's `true`, WordPress reports all PHP errors, warnings, notices and deprecation messages, including WordPress's own notices about deprecated functions. The other constants control **where** those messages go and **what extra information** WordPress collects.

The official reference is the [Debugging in WordPress](https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/) page in the WordPress developer documentation.

## Every WordPress debugging constant

| Constant | Default | What it does |
|-|-|-|
| `WP_DEBUG` | `false` | Master switch. Reports all PHP errors, warnings and notices. |
| `WP_DEBUG_LOG` | `false` | Saves errors to `wp-content/debug.log`, or to a custom path. Only works when `WP_DEBUG` is on. |
| `WP_DEBUG_DISPLAY` | `true` | Shows errors on the page. Set to `false` on live sites. |
| `SCRIPT_DEBUG` | `false` | Loads the unminified versions of WordPress core CSS and JavaScript. |
| `SAVEQUERIES` | `false` | Stores every database query, with timing and the calling function, for inspection. |

### WP_DEBUG

```php
define( 'WP_DEBUG', true );
```

On its own, this shows errors on screen, because `WP_DEBUG_DISPLAY` defaults to `true`. **That's fine on a local or [staging site](https://mykavo.app/blog/wordpress-staging-site), but not on a live site**, where error messages can reveal file paths and break page layouts for visitors.

### WP_DEBUG_LOG

```php
define( 'WP_DEBUG_LOG', true );
```

This writes every error to `wp-content/debug.log`. The file is created the first time an error is logged, so if it doesn't exist yet, reload the broken page.

**Use a custom log path.** Since WordPress 5.1, you can pass a file path instead of `true`:

```php
define( 'WP_DEBUG_LOG', '/home/youruser/logs/wp-errors.log' );
```

Pick a folder **outside your public web root** (outside `public_html` or `www`), so the file can't be downloaded from a browser. The folder must exist and be writable by PHP, or nothing will be logged.

### WP_DEBUG_DISPLAY

```php
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
```

Setting this to `false` stops WordPress from printing errors into your pages. The `ini_set` line makes sure PHP itself doesn't display them either, in case your server's PHP configuration has `display_errors` turned on.

### SCRIPT_DEBUG

```php
define( 'SCRIPT_DEBUG', true );
```

WordPress normally loads minified versions of its core CSS and JavaScript. `SCRIPT_DEBUG` loads the full development versions instead, which makes JavaScript errors in the browser console readable. **Use it when debugging the block editor, admin screens or core scripts**, and switch it off afterward, since the unminified files are larger.

### SAVEQUERIES

```php
define( 'SAVEQUERIES', true );
```

This stores every database query in `$wpdb->queries`, along with how long it took and which function ran it. It's useful for finding slow queries but **adds overhead to every page load**, so only enable it briefly, ideally on staging. Query Monitor (below) displays the same information in a readable panel.

## Where to put the code in wp-config.php

`wp-config.php` sits in your WordPress root folder, the same folder that contains `wp-admin` and `wp-content`.

1. **Download a copy first** so you can restore it if you make a typo. A single missing semicolon can take the whole site down.
2. **Search for `WP_DEBUG`.** Most installs already have `define( 'WP_DEBUG', false );`. Edit that line rather than adding a second definition, which causes a "constant already defined" warning.
3. **Add the other constants directly below it**, and above the comment that says `/* That's all, stop editing! Happy publishing. */`. Anything placed after the line that loads `wp-settings.php` runs too late to take effect.

### Enable debug mode with WP-CLI

If you have SSH access, WP-CLI edits `wp-config.php` for you:

```bash
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
wp config set WP_DEBUG_DISPLAY false --raw
```

The `--raw` flag writes `true` and `false` as PHP values instead of text strings, which matters: the string `'false'` would actually count as true.

Some managed hosts also offer a debug toggle in their dashboard. It does the same thing; check your host's help center for where they write the log.

## How to read debug.log

Open the log with your host's file manager, download it via SFTP, or follow it live over SSH:

```bash
tail -f wp-content/debug.log
```

Each line has a timestamp, an error type, a message, and the file and line number where it happened. **The file path is the most useful part**, because it tells you which plugin or theme is responsible:

```
[23-Nov-2026 10:42:17 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function example_function() in /var/www/html/wp-content/plugins/example-plugin/includes/init.php:42
```

Here the problem is inside `wp-content/plugins/example-plugin`. Paths under `wp-content/themes/` point to a theme.

### What the error types mean

| Type | Severity | What to do |
|-|-|-|
| **Fatal error** | Stops the page from loading | Fix first. Usually causes the [critical error](https://mykavo.app/blog/wordpress-critical-error) message or a [white screen](https://mykavo.app/blog/wordpress-white-screen-of-death). |
| **Warning** | Code continued, but something went wrong | Investigate; often a sign of a coming failure. |
| **Notice** | Minor issue, such as an undefined variable | Usually safe to ignore on production; report to the developer. |
| **Deprecated** | Code uses something that will be removed | Update the plugin or theme. Common after a PHP upgrade. |

Common fatal errors and what they point to:

- **"Allowed memory size exhausted"**: raise the [WordPress memory limit](https://mykavo.app/blog/wordpress-memory-limit) or find the plugin using too much.
- **"Call to undefined function"** or **"Class not found"**: a plugin is missing a dependency, or a plugin or theme is incompatible with your PHP or WordPress version.
- **"Cannot redeclare"**: two plugins define the same function. Our [plugin conflict guide](https://mykavo.app/blog/wordpress-plugin-conflict) shows how to isolate it.

**Clear the log before you reproduce the problem.** Old entries make it hard to see which errors belong to the issue you're chasing. Delete or empty `debug.log`, reload the broken page once, then read what was written.

## Keep debug.log private

The default location, `wp-content/debug.log`, is inside your public web folder. Anyone who guesses the URL can download it and see file paths, plugin names and sometimes data passed in errors. WordPress's Site Health screen warns about this when logging is on.

**The best fix is a custom path outside the web root**, shown above. If you must keep the default location, block access to the file.

On **Apache** (most shared hosting), add this to the `.htaccess` file in your WordPress root:

```apache
<Files "debug.log">
  Require all denied
</Files>
```

On **Nginx**, add this inside your site's `server` block and reload Nginx:

```nginx
location ~* /debug\.log$ {
    deny all;
}
```

Then try to open `https://yourdomain.com/wp-content/debug.log` in a private window. You should get a 403 Forbidden response, not the file. Our [WordPress security](https://mykavo.app/blog/wordpress-security) guide covers other files worth locking down.

## Query Monitor: debugging inside wp-admin

[Query Monitor](https://wordpress.org/plugins/query-monitor/) is a free plugin that adds a debugging panel to the admin bar, visible only to administrators. It shows:

- PHP errors, warnings and notices on the current page, with the plugin or theme responsible.
- Every database query, with slow and duplicate queries highlighted.
- HTTP API calls to external services, and whether they failed.
- Hooks, enqueued scripts and styles, and the template file being used.

**Query Monitor works without editing `wp-config.php`**, which makes it a good first step when the site still loads. Deactivate it when you're done, since it adds overhead to admin page loads.

## Recovery mode: when you can't reach wp-admin

Since WordPress 5.2, when a plugin or theme causes a fatal error, WordPress shows a critical error message and **emails the site's admin address a recovery mode link**. Clicking it logs you in with the broken plugin or theme paused, so you can deactivate or update it.

- The email goes to the address in **Settings > General**, unless you set a different one with `define( 'RECOVERY_MODE_EMAIL', 'you@example.com' );`.
- If the email never arrives, your site may not be able to send mail at all. See our guide to [WordPress not sending email](https://mykavo.app/blog/wordpress-not-sending-email).
- No email and no wp-admin access? Rename the plugin's folder in `wp-content/plugins` via SFTP to deactivate it, then use `debug.log` to confirm the cause.

## Turn debug mode off when you're done

Leaving debugging on is a common mistake. The log keeps growing, can fill your disk, and exposes information about your site.

1. **Set `WP_DEBUG` back to `false`** in `wp-config.php` (or run `wp config set WP_DEBUG false --raw`).
2. **Remove or disable** `SCRIPT_DEBUG` and `SAVEQUERIES` if you added them.
3. **Delete `debug.log`** once you've saved anything you need.
4. **Check Tools > Site Health > Info** under WordPress Constants to confirm the debug values are off.

For ongoing error tracking on a live site, server-level PHP error logs from your host are a better long-term option than leaving WP_DEBUG on.

## How to catch errors before visitors do

Debug mode helps once you know something is wrong. The hard part is knowing. **Many PHP errors don't take a whole site down**: they break one template, a product page, or a checkout step, while the homepage looks fine.

MyKavo watches the pages you choose and re-scans them on a schedule (weekly on the Free plan, daily on paid plans). It alerts you when a page's HTTP status changes (for example from 200 to 500), when an H1, title or important element disappears, or when the page changes visually, with before-and-after screenshots and a severity so you know what to fix first. The free [MyKavo WordPress plugin](https://mykavo.app/wordpress-plugin) runs those checks after every plugin, theme and core update and names the update that broke something, which tells you exactly where to start reading `debug.log`.

## Frequently asked questions

### How do I enable debug mode in WordPress?

Edit wp-config.php and set define( 'WP_DEBUG', true ); above the "That's all, stop editing!" line. On a live site, also set WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false so errors go to a log file instead of the screen.

### Where is the WordPress debug log?

By default it's wp-content/debug.log, created the first time an error is logged. If WP_DEBUG_LOG is set to a file path instead of true, the log is written to that path.

### Is it safe to enable WP_DEBUG on a live site?

Yes, briefly, if you log errors and hide them from visitors with WP_DEBUG_DISPLAY set to false. Protect or move debug.log so it can't be downloaded, and turn debugging off as soon as you've found the problem.

### Why is debug.log not being created?

Either no error has happened since you enabled it, WP_DEBUG is still false, the constants were added below the line that loads wp-settings.php, or PHP can't write to the folder. Reload the broken page and check file permissions.

### What is the difference between WP_DEBUG and WP_DEBUG_LOG?

WP_DEBUG turns error reporting on. WP_DEBUG_LOG decides whether those errors are saved to a log file. WP_DEBUG_LOG does nothing unless WP_DEBUG is also true.

### How do I turn off WordPress debug mode?

Set define( 'WP_DEBUG', false ); in wp-config.php, remove SCRIPT_DEBUG and SAVEQUERIES if you added them, and delete debug.log. You can confirm the values under Tools > Site Health > Info.

## The bottom line

WordPress debug mode is the fastest way to turn a blank page or critical error into a specific file and line number. On a live site, log errors with WP_DEBUG_LOG, hide them with WP_DEBUG_DISPLAY set to false, keep the log out of public reach, and switch everything off when you're done. Use Query Monitor when the site still loads, and recovery mode when it doesn't.

**Find out what broke before your visitors do.** [Start monitoring your site free with MyKavo](https://mykavo.app/signup) and install the free [MyKavo WordPress plugin](https://mykavo.app/wordpress-plugin), no card needed.
