How to Disable WP_DEBUG in WordPress, in the previous post, we discussed how to enable it: https://marketist.co/blog/how-to-enable-wp_debug-in-wordpress/
Let’s discuss WP_DEBUG
is a debugging tool built into WordPress that helps developers identify PHP errors, warnings, and notices. While it’s incredibly helpful during development or troubleshooting, it’s not something you want running on a live website.
If left enabled, WP_DEBUG can reveal error messages directly on your site, which not only looks unprofessional but can also expose sensitive details about your server or theme setup to potential hackers.
Why You Should Disable WP_DEBUG on a Live Site
Leaving WP_DEBUG on in a production environment can cause problems like:
-
Publicly displayed error messages
-
Security vulnerabilities (file paths, plugin versions, etc.)
-
Reduced user trust and professional image
-
Log file overload from constant error logging
When Should You Disable WP_DEBUG?
-
Before launching a new website
-
After completing plugin/theme development
-
Once you’ve fixed the issue you were debugging
-
On staging or test environments when you’re ready to go live
How to Disable WP_DEBUG in WordPress
Disabling WP_DEBUG is a quick process that involves editing one file: wp-config.php
.
Step 1: Open wp-config.php
Use FTP, cPanel File Manager, or your local code editor to access your WordPress installation. Look for the wp-config.php
file in the root folder.
Step 2: Add or Modify the Debugging Settings
Locate any lines that define debug constants. Change them to the following:
📌 Tip: Make sure these lines are placed above this line in wp-config.php
:
These settings ensure:
-
PHP errors are no longer shown to visitors
-
PHP does not display any errors
-
WP_DEBUG is completely turned off
Should I Remove the debug.log
File?
If you’ve previously enabled WP_DEBUG_LOG
, there may be a debug.log
file inside /wp-content/
.
-
It’s safe to delete this file after turning debugging off.
-
You can also remove this line from
wp-config.php
if it’s present:
What If You Still See Errors on Your Site?
Here are a few quick checks:
-
Double-check the placement of your
define()
lines (they must be above the “Happy publishing” comment). -
Clear your site and browser cache.
-
Ensure there are no server-level overrides in
.htaccess
orphp.ini
. -
Disable any plugin that might force error display.
Bonus Tip: Use a Staging Environment for Debugging
Instead of debugging directly on your live website, use a staging site (most hosting providers offer one-click staging). This keeps your main site safe and ensures your visitors never see raw errors.
Conclusion:
Disabling WP_DEBUG in WordPress is just as important as enabling it—especially when you’re done troubleshooting or launching a site. Keeping your site secure, clean, and professional should always be a top priority.
FAQs:
How do I disable WP_DEBUG in WordPress?
Edit your wp-config.php
file and set WP_DEBUG
to false
:
Should I delete the debug log file after disabling WP_DEBUG?
Yes, it’s safe (and recommended) to delete the /wp-content/debug.log
file after disabling debugging. It helps free up server space and keeps sensitive logs from sitting around.
What happens if I forget to turn off WP_DEBUG?
Your visitors might see error messages, your site could appear broken or unprofessional, and you might expose sensitive file paths or other details that hackers can exploit.
Is it okay to leave WP_DEBUG on in staging or development?
Yes! WP_DEBUG is designed for development and staging environments. It should be turned off only in live/production environments.
Follow Marketist Blog to stay updated on WordPress