WordPress debug mode helps display or save technical errors that are not always visible on the website. It is useful when a WordPress website shows a blank page, a critical error, a 500 error, or unexpected behavior after a plugin, theme, or PHP change.
Debug mode should usually be enabled only while troubleshooting. After the issue is identified, it should be disabled again to avoid storing unnecessary error logs or showing technical information.
Table of Contents
Before you start
To enable WordPress debug mode, you need access to the website files. The setting is added in the wp-config.php file, which is located in the main WordPress directory.
You can access the file by using FTP or SFTP.
Related article: How to Create a New FTP Account
How to enable debug mode in WordPress
- Connect to your website files using FTP or SFTP.
- Open the main directory of your WordPress website.
- Find the file named
wp-config.php. - Download a backup copy of the file before editing it.
- Open
wp-config.phpin a text editor. - Look for this line:
define( 'WP_DEBUG', false );
- Replace it with the following code:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
- Save the file.
- Upload the updated
wp-config.phpfile back to the server if you edited it locally. - Open the website again and repeat the action that caused the problem.
WordPress will now save detected errors in a log file instead of showing them directly to visitors.
Where WordPress saves the debug log
When WP_DEBUG_LOG is enabled, WordPress usually saves errors in this file:
wp-content/debug.log
Open this file after reproducing the issue. The newest errors are usually added at the bottom of the file.
The log may mention a plugin, theme, PHP function, missing file, or database issue. This information helps identify what is causing the problem.
Related article: How to Check for Errors in CMS WordPress
What the debug settings mean
define( 'WP_DEBUG', true );
This enables WordPress debug mode.
define( 'WP_DEBUG_LOG', true );
This tells WordPress to save errors to a log file.
define( 'WP_DEBUG_DISPLAY', false );
This prevents errors from being displayed directly on the website.
@ini_set( 'display_errors', 0 );
This helps keep technical errors hidden from visitors while they are still saved in the log.
This configuration is usually safer for live websites because it records errors without displaying them publicly.
If the website shows a 500 error
A 500 error means the server could not complete the request. In WordPress, this is often caused by a plugin, theme, PHP version change, corrupted file, or configuration issue.
After enabling debug mode, check the debug.log file for the exact error message.
Related article: Error 500 Internal Server Error
If the error points to a plugin
If the debug log shows that a plugin is causing the problem, you can disable that plugin without logging in to the WordPress admin panel.
This is useful when the WordPress dashboard is not accessible.
Related article: How to Disable a Plugin in WordPress Without Accessing the Backend
How to disable debug mode
After troubleshooting, open wp-config.php again and change debug mode back to:
define( 'WP_DEBUG', false );
You can also remove these lines if they were added only for troubleshooting:
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
If the wp-content/debug.log file contains many old errors, you can download it for reference and then remove it from the server.
What to expect
Debug mode does not fix the problem by itself. It helps show where the problem is coming from.
In most cases, the log points to a plugin, theme, PHP compatibility issue, missing file, or database-related error. Once the cause is known, the next step is to update, disable, repair, or reconfigure the affected part of the website.
Summary
WordPress debug mode is used to collect technical error information during troubleshooting. The safest approach on a live website is to save errors in wp-content/debug.log while keeping them hidden from visitors.
After the issue is identified, debug mode should be disabled again.