---
title: "Debugging in WordPress Studio"
description: "WordPress Studio has a debug log, error display, phpMyAdmin, and Xdebug built in, so you can debug a local site without installing anything."
sidebar:
  label: "Debugging"
---

Most debug settings live on the **Debug** page of a site’s settings, and each one sets a WordPress constant for you. phpMyAdmin opens from the site preview, and Xdebug has its own page.

**Applies to:** every local site, in the WordPress Studio app and WordPress Studio CLI. You don’t need a WordPress.com account.

## Open the Debug settings

To open a site’s **Debug** page:

1.  Choose **Settings** from the site menu. To open the site menu, click the **Site menu** button with the site’s name at the top left of the site’s header, or right-click the site in the sidebar.
2.  Select the **Debug** page.

Change any setting, then click **Save** at the top of the dialog. You can’t change these settings while a publish, pull, import, or export is running on the site.

The **Debug** page has these settings:

| Setting | What it sets | What it does |
| --- | --- | --- |
| **Environment** | `WP_ENVIRONMENT_TYPE` | The value `wp_get_environment_type()` returns: **Local** (the default), **Development**, **Staging**, or **Production** |
| **Xdebug** | Loads the Xdebug extension | Step-through debugging. See [Xdebug in WordPress Studio](/docs/xdebug/) |
| **Debug log** | `WP_DEBUG` and `WP_DEBUG_LOG` | Writes PHP errors to `wp-content/debug.log` |
| **Script debugging** | `SCRIPT_DEBUG` | Loads unminified WordPress JavaScript and CSS |
| **Show errors in browser** | `WP_DEBUG` and `WP_DEBUG_DISPLAY` | Prints PHP errors, warnings, and notices in the page |

## Turn on the debug log

<span id="debug-log"></span><span id="enabling-the-debug-log"></span>The debug log saves PHP errors, notices, and warnings to `wp-content/debug.log` in the site’s folder.

1.  Open the site’s **Debug** page.
2.  Turn on **Debug log**.
3.  Click **Save**. Once the log file exists, an **Open log file** button appears under **Debug log**.

To turn it on from the terminal, run `studio config set --debug-log` from the site’s directory.

To write your own messages to the log, use PHP’s `error_log()` function:

```php
error_log( 'My value: ' . print_r( $my_variable, true ) );
```

## Show errors in the browser

<span id="show-errors-in-browser"></span>**Show errors in browser** prints PHP errors and warnings in the page, so you see them as soon as you load it. Use it alongside the debug log, which keeps a record you can read later.

To turn it on, turn on **Show errors in browser** on the site’s **Debug** page and click **Save**, or run `studio config set --debug-display`.

Turn it off before you share the site, for example as a [preview](/docs/preview-sites/). Error messages can show file paths and other details about your code.

## Load unminified scripts and set the environment

<span id="script-debug-and-environment-type"></span>**Script debugging** sets `SCRIPT_DEBUG`, so WordPress loads the development versions of its core CSS and JavaScript instead of the minified files. Turn it on to read full React error messages in the block editor. From the terminal, run `studio config set --script-debug`.

**Environment** sets the value `wp_get_environment_type()` returns. Plugins and themes read it to behave differently in each environment. From the terminal, run `studio config set --environment-type <type>`, where `<type>` is `local`, `development`, `staging`, or `production`.

## Ask an AI agent to read the debug log

<span id="using-ai-agents-to-interpret-debug-logs"></span>Once the debug log is on, an AI agent can read it and suggest fixes. Tell the agent, such as [WordPress Studio Code](/docs/studio-code/), Claude Code, or Cursor, that the site’s errors are in `wp-content/debug.log`. For example:

```text
Read wp-content/debug.log and fix the errors from my plugin.
```

## Open the database in phpMyAdmin

<span id="database-access-with-phpmyadmin"></span>phpMyAdmin lets you browse tables, run queries, and edit data in a site’s database. To open it, select the site and do one of these:

- Click **New tab** (**+**) above the site preview and choose **Database**, or choose **Tools → Database** from the site menu. phpMyAdmin opens in a tab of the preview.
- Choose **Open in → phpMyAdmin** from the site menu to open it in your browser.

If the site is stopped, WordPress Studio starts it first.

![The New tab menu in WordPress Studio's site preview, open next to the preview tab, with Browser, Admin, Design System, Database, and Email log.](/wp-content/uploads/docs/preview-destinations.webp)

WordPress Studio’s phpMyAdmin works with SQLite, the database WordPress Studio sites use by default. If a site uses an external MySQL server instead (see [How can I use WordPress Studio with the MySQL server of my choice?](/docs/frequently-asked-questions/#how-can-i-use-wordpress-studio-with-the-mysql-server-of-my-choice)), **Database** and **phpMyAdmin** are unavailable for it. Use a separate database client for that site.

## Step through code with Xdebug

<span id="step-through-debugging-with-xdebug"></span>[Xdebug](https://xdebug.org/) lets you set breakpoints, step through PHP line by line, and inspect variables from your code editor. It ships with WordPress Studio and runs on one site at a time. When it’s on, each request connects to your editor on port `9003`.

To set it up with Visual Studio Code or PhpStorm, see [Xdebug in WordPress Studio](/docs/xdebug/).

## Troubleshooting

### Why don’t my WP_DEBUG changes in wp-config.php stick?

WordPress Studio writes `WP_DEBUG`, `WP_DEBUG_LOG`, `WP_DEBUG_DISPLAY`, `SCRIPT_DEBUG`, and `WP_ENVIRONMENT_TYPE` to the site’s `wp-config.php` each time the site starts, using the **Debug** page settings. Change them on the **Debug** page or with `studio config set` instead.

WordPress Studio also sets `WP_DEVELOPMENT_MODE` to `'theme'` in `wp-config.php` when none is set, so new block theme patterns show up right away without clearing the cache. Any `WP_DEVELOPMENT_MODE` value you set yourself is kept, and the default `'theme'` value is left out when you push or export.

### Why is there no Open log file button?

The button appears once `wp-content/debug.log` exists. WordPress creates the file the first time it logs something. Load a page of the site, then check again.

### Why are Database and phpMyAdmin unavailable?

The site uses an external MySQL server. WordPress Studio’s phpMyAdmin works only with SQLite. Use a separate database client that connects to your MySQL server.

## Related

- [Xdebug in WordPress Studio](/docs/xdebug/)
- [PHP runtimes](/docs/php-runtimes/)
- [WordPress Studio sites](/docs/sites/#site-settings)
- [WordPress Studio CLI](/docs/cli/)
