# How to debug errors in WordPress

URL: https://wp24x7.com/how-to-debug-error-in-wordpress/
Updated: 2026-11-29
Type: blog post
Audience: WordPress site owners and developers

> 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.

## Key facts

- 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.**

> **Quick answer**
Add `WP_DEBUG` and `WP_DEBUG_LOG` as true and `WP_DEBUG_DISPLAY` as false above the "stop editing" comment in `wp-config.php`, reproduce the problem, read `wp-content/debug.log`, then switch it all off and delete the log. Back up or use staging first.

## 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 says | What it usually means |
|---|---|
| Fatal error, with a path | The plugin or theme in that path is the culprit or is missing a dependency |
| Allowed memory size exhausted | A script ran out of PHP memory; find what was running before raising the limit |
| Call to undefined function | A plugin needing another plugin, or a PHP version mismatch after an update |
| Database errors | Check 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.

| Level | Meaning |
|---|---|
| Fatal error | Execution stopped; the page is broken |
| Warning | Something went wrong but the page continued |
| Notice or deprecated | Works 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?

| Constant | Use | Caution |
|---|---|---|
| `SCRIPT_DEBUG` true | Loads unminified core scripts and styles for readable console errors | Turn off afterwards |
| `WP_DEBUG_DISPLAY` false plus `@ini_set( 'display_errors', 0 );` | Stops anything printing even when a plugin changes settings | None |
| `SAVEQUERIES` true | Records queries for Query Monitor | Slows 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?

> **Common mistakes**
Adding the `define` lines below the "stop editing" comment, where they are ignored. Defining `WP_DEBUG` twice with different values. Leaving `WP_DEBUG_DISPLAY` true on a live site, which prints paths to visitors. Fixing three things and not knowing which worked. Forgetting a caching plugin may serve the old page: clear caches before testing again.

## Still stuck?

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

**Need a second pair of eyes?**
Send the last lines of your log.
[Post a project](/post-project)
[Call the help desk: (804) 375-4450](tel:+18043754450)

## Frequently asked questions

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.
