How to Enable Debugging in WordPress
WordPress includes built-in debugging tools that can help identify PHP errors, warnings, notices, plugin conflicts, and other technical issues. When troubleshooting a problem on your site, enabling debug logging allows WordPress to save error details to a log file so they can be reviewed later without displaying them publicly to visitors.
Before You Begin
Before editing your WordPress files, create a recent backup of your website or make the change in a staging environment when possible. Debugging tools are best used for troubleshooting and development, and should not be left enabled permanently on a live production site.
Step 1: Access Your WordPress Files
To enable debugging, you will need access to your site files using one of the following:
- FTP or SFTP
- Your hosting file manager
- A server control panel such as cPanel or Plesk
Once connected, open the root folder of your WordPress installation and locate:
wp-config.php
Step 2: Edit the wp-config.php File
Open wp-config.php and look for this line:
define( 'WP_DEBUG', false );
If it exists, replace it with the code below. If it does not exist, add the code before this line:
/* That's all, stop editing! Happy blogging. */
Use this recommended debugging setup:
// Enable WordPress debugging.
define( 'WP_DEBUG', true );
// Save errors, warnings, and notices to wp-content/debug.log.
define( 'WP_DEBUG_LOG', true );
// Do not display errors publicly on the website.
define( 'WP_DEBUG_DISPLAY', false );
// Reinforce hiding PHP errors from public view.
@ini_set( 'display_errors', 0 );
This setup enables WordPress debugging, writes error details to a log file, and prevents those messages from appearing on the front end of the website.
Step 3: Save the File
After adding the code, save the updated wp-config.php file and upload it back to your server if you are using FTP or SFTP.
Step 4: Reproduce the Problem
Return to your WordPress site and repeat the action that caused the issue. For example:
- Reload the page showing the error
- Submit the form again
- Run the plugin feature that failed
- Revisit the admin screen that is not loading correctly
This helps WordPress capture the related errors in the debug log.
Step 5: Find the Debug Log
Once debugging is enabled, WordPress stores the log file here:
/wp-content/debug.log
Open that file and review the latest entries near the bottom. The most recent lines are often the most useful when diagnosing the issue.
Step 6: Turn Debugging Off After Troubleshooting
After you finish reviewing the log, it is recommended to disable debugging again by changing:
define( 'WP_DEBUG', true );
back to:
define( 'WP_DEBUG', false );
You may also remove or disable the additional debug lines if they are no longer needed. Debugging should not remain enabled on a production site longer than necessary.
Recommended Debug Configuration
For most support and troubleshooting cases, this is the safest setup:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
This captures useful error details privately in debug.log without exposing technical warnings to site visitors.
