It happens to all of us; there’s some issue or error with our site, and we need to do some troubleshooting to figure out what’s causing the issue and how to solve it.

WordPress has a built-in debug mode to help you track down what’s going on by displaying all PHP errors, notices, and warnings. There are also additional debugging options that can be helpful when investigating specific types of issues.

Once you identify the source of an issue, you can report the details to the plugin or theme developer or your website’s developer. If an immediate fix isn’t available, you may need to deactivate the plugin or theme until it can be resolved.

Enable WP_DEBUG

To enable WP_DEBUGLog in to MyKinsta, and select the site and environment you want to enable it on.

Go to the Tools tab and click the Enable button under WordPress debugging.

Enable WordPress debugging in MyKinsta.
Enable WordPress debugging in MyKinsta.

This will make WordPress show any and all PHP errors, notices, and warnings on your site. These will be shown to any visitor and may be shown on both the front of your site and in the WordPress dashboard.

If you view your site’s wp-config.php file now, you’ll see the following line has been added just before the /* That's all, stop editing! Happy blogging. */ line:

if (! defined('WP_DEBUG') ) { define( 'WP_DEBUG', true ); } // line added by the MyKinsta

Setting WP_DEBUG to true enables debugging in WordPress.

Extending WP_DEBUG

There are a few constants that serve as companions to WP_DEBUG by enabling additional debugging options.

Debug Log

If you’d like to save errors to a log file, you can enable WP_DEBUG_LOG by editing your wp-config.php file and adding the following line after the line that enables WP_DEBUG:

define( 'WP_DEBUG_LOG', true );

By default, this log file will be saved to: wp-content/debug.log on the server. If you like, you can customize the path and file name. In this example, we’re saving the log file to the tmp directory and naming the file wp-errors.log:

define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' );

Script Debug

Enabling SCRIPT_DEBUG forces WordPress to use the dev versions of core CSS and JavaScript files instead of the minified versions that it usually loads:

define( 'SCRIPT_DEBUG', true );

This can be helpful when troubleshooting JavaScript or CSS issues and you suspect a conflict or other problem with core JavaScript or CSS files.

Database Query Debugging

To save database queries to an array, enable SAVEQUERIES:

define( 'SAVEQUERIES', true );

This will save each query with how long each query took to execute and what function called the query. The array can be accessed or displayed with the global $wpdb->queries.

Other Debugging Tools and Resources

Query Monitor Plugin

The Query Monitor plugin is a free plugin that’s helpful for debugging a number of different areas in WordPress. It can help you track down slow database queries, AJAX calls, REST API requests, and much more. For more details, we have a blog post on how to use the Query Monitor plugin.

Kinsta APM

Kinsta’s APM tool helps you identify PHP performance bottlenecks on your WordPress site without having to sign up for third-party monitoring services like New Relic.

New Relic

New Relic is a monitoring tool that gives you detailed performance breakdowns on a granular level.

Server Logs

Log files are available in MyKinsta and can also be downloaded via SFTP. These files can be helpful when troubleshooting errors or tracking down other issues on your site.