Available for projects & agency overflow · Quick reply, from the person who does the work

How to enable debug mode on WordPress

WP_DEBUG reveals the exact file, line and message behind a "critical error on this website" or a blank screen. Set up correctly, it writes this information to a log without ever showing it to visitors.

Describe my issue Send a message

wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Enabling debug mode without exposing the site

  1. Access the site's files

    wp-config.php sits at the root of the WordPress installation, at the same level as the wp-content, wp-admin and wp-includes folders. FTP, SFTP or access to the host's file manager is required.

  2. Find the line to edit

    Look for the line define('WP_DEBUG', false); If it doesn't exist, add the three constants just before the line /* That's all, stop editing! Happy publishing. */.

  3. Separate display from logging

    WP_DEBUG_DISPLAY set to false stops messages from appearing on public pages. WP_DEBUG_LOG set to true writes them to a file instead, which is the combination to use on a live site.

  4. Reproduce the problem

    Reload the page or action that triggers the error so WordPress logs the event.

  5. Read wp-content/debug.log

    This file lists PHP errors in chronological order, with the file, the line, and often the plugin or theme at fault.

  6. Switch back to normal mode

    Once the cause is identified, set WP_DEBUG and WP_DEBUG_LOG back to false, and delete the debug.log file if it holds sensitive information.

Why separate display from logging

WordPress's default configuration hides every error behind the generic message "There has been a critical error on this website", introduced since WordPress 5.2 to avoid exposing code to visitors. That's good protection, but it makes diagnosis impossible without file access.

Enabling WP_DEBUG alone is enough to make errors appear directly on the page, which is handy locally but dangerous in production: any visitor would then see the same messages, sometimes including file paths or internal function names. The combination of WP_DEBUG_LOG set to true and WP_DEBUG_DISPLAY set to false resolves that trade-off: errors keep being recorded, but only someone with access to the server's files can view them.

On a WooCommerce store, this setting is complemented by reading the plugin's own logs, accessible from WooCommerce, Status, Logs in the admin, which record payment, webhook and stock synchronisation errors separately.

Common mistakes

  • Leaving WP_DEBUG_DISPLAY set to true on a live site: errors become visible to every visitor, including exploitable technical information.
  • Forgetting that the debug.log file grows indefinitely once enabled: on a site generating a lot of PHP notices, it can reach several hundred megabytes within a few weeks.
  • Looking for wp-content/debug.log when it doesn't exist yet: WordPress only creates it once a first error occurs after enabling debug mode.
  • Editing wp-config.php without a prior backup: a syntax error in this file makes the entire site inaccessible, including wp-admin.

Frequently asked questions

Can debug mode make the critical error worse?
No, it doesn't modify any data or file other than the log. It only changes how WordPress handles and displays its own errors.
wp-config.php doesn't exist or I can't find it, what should I do?
This file exists on every functional WordPress installation, at the site's root. If it can't be found, the installation may be incomplete, or the FTP access may be pointing to the wrong folder.
The debugger shows several different errors, which one should I address first?
Generally the first one chronologically in the log: the ones that follow are often cascading consequences of the first, for example a plugin that fails to load followed by others that depend on it.
Should debug mode be enabled on a WordPress multisite install?
Yes, the method is identical: the constants are declared in the same wp-config.php shared by the whole network of sites.
Is there a more complete tool than debug.log for diagnosing WordPress?
The Query Monitor plugin adds a debug bar directly in the admin and the front end, with a breakdown of the SQL queries executed, the hooks triggered, and the plugins responsible for each slowdown or error, on top of WP_DEBUG.

Describe your need in one minute

A few targeted questions so I can reply with an estimate rather than another questionnaire.

impact
message
declencheur
debug (facultatif)
acces (facultatif)
Please provide an email or a phone number so I can get back to you.

Please provide an email or a phone number so I can get back to you.