β²οΈ Estimated reading time: 2 min
π Fix WordPress Debug Mode Security Warning
Your WordPress Site Health is warning you that WP_DEBUG_LOG
is enabled, which can expose sensitive information in a publicly accessible file (/wp-content/debug.log
).
β How to Fix This Warning
There are two options to fix this:
1οΈβ£ Disable Debug Mode (Recommended for Live Sites)
If you no longer need debugging, disable it by editing your wp-config.php
file.
πΉ Steps
Access your server via FTP, cPanel, or SSH.
Open wp-config.php
, located in the root directory (/public_html/
or /var/www/html/
).
Find these lines:
define('WP_DEBUG', true);define('WP_DEBUG_LOG', true);define('WP_DEBUG_DISPLAY', false);
Change them to:
define('WP_DEBUG', false);define('WP_DEBUG_LOG', false);define('WP_DEBUG_DISPLAY', false);
Save the file and refresh your WordPress Site Health page.
2οΈβ£ Keep Debug Mode Enabled but Secure the Log File
If you need debugging but want to protect the log file, move it to a non-public location.
πΉ Steps
- Move the log file outside the web-accessible directory.
- Change this line in
wp-config.php
:define('WP_DEBUG_LOG', true);
- To:
define('WP_DEBUG_LOG', '/home/yourusername/logs/debug.log');
// Replace with a secure path - This ensures that only users with server access can see it.
- Change this line in
- Prevent public access to
debug.log
with.htaccess
(For Apache Servers)- Edit
.htaccess
in thewp-content/
directory and add:<Files "debug.log"> Order allow,deny Deny from all </Files>
- Edit
- For Nginx Servers, block access via configuration:
- Edit your Nginx config file (
/etc/nginx/sites-available/default
or similar):location ~* /wp-content/debug.log { deny all; access_log off; log_not_found off; }
- Restart Nginx:
sudo systemctl restart nginx
- Edit your Nginx config file (

β Verify the Fix
- Go to WordPress Dashboard > Tools > Site Health.
- Check if the debug mode warning is gone.
π Final Steps
Disable debug mode for live sites
Move debug logs to a non-public location if needed
Secure logs using .htaccess
or Nginx rules
Now your WordPress site is secure! Let me know if you need help. π₯
Only logged-in users can submit reports.
Discover more from HelpZone
Subscribe to get the latest posts sent to your email.