Debug mode is a built-in WordPress feature that reveals the PHP errors, warnings and notices happening behind the scenes. You turn it on with a single constant called WP_DEBUG in your wp-config.php file.
When your site breaks and shows no useful message, debug mode tells you exactly which file and line caused the trouble.
How does WP_DEBUG work?
By default, WP_DEBUG is set to false, and WordPress keeps most warnings and notices quiet. When you set it to true, WordPress starts reporting every problem it finds. Think of it as switching on the lights in a dark room, so you can see what you tripped over.
Two helper constants make debug mode safer to use:
WP_DEBUG_LOGsaves errors to a file nameddebug.loginside thewp-contentfolder.WP_DEBUG_DISPLAYcontrols whether errors are printed on the screen.
How to enable debug mode in WordPress
- First, open
wp-config.phpin your site's root folder using FTP or your host's file manager. - Next, find the line that defines
WP_DEBUGand replace it with the code below. If there is no such line, add the code just above the comment that tells you to stop editing. - Now, save the file and reload the page that shows the problem.
- Finally, open
wp-content/debug.logto read the errors.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
This setup records every error in the log file without showing it to your visitors. Our guide on how to debug in WordPress covers more ways to track down problems.
Turn it off when you are done
Debug mode is a tool for fixing problems, not for everyday use. Once you solve the issue, set WP_DEBUG back to false and delete the old log file.
Never leave debug mode running on a live site for long. On many servers, anyone who knows the address of debug.log can open it, and it may reveal file paths and other details about your site.
Debug mode turns a mysterious problem into a clear error message you can act on. That's it. If an error in your log doesn't make sense, ask us about it in the comments below.