How to Enable WordPress Debugging Mode to Fix Errors

How can you enable debugging mode in WordPress or get more information about WordPress errors displayed on a web browser? If you are a WordPress user or developer and are asking these questions, you have landed on the right resource. This guide will show you how to enable WordPress’s debugging features.

WordPress provides several powerful debugging tools both for developers and non-programmer or general users, that you can enable using available configuration options. These options once enabled help you quickly find and resolve errors by showing the detailed error information.

We will demonstrate using the following error which we encountered while setting up a dummy site for testing purposes.

WordPress Database Connection Error

WordPress Database Connection Error

When you look at this error, there is no much information that accompanies it. There could be many causes to it: the database server could be down or the database connection settings (i.e database name, database user, and the user’s password) defined in the wp-config.php configuration file could be wrong.

So how can we get more information about the above error? The WP_DEBUG option is a PHP permanent global variable that activates the “debug” mode throughout WordPress thus causing all PHP errors, notices, and warnings to be displayed on the browser.

This “debug” feature was added in WordPress version 2.3.1 and is configured in wp-config.php – one of the most important files in your WordPress installation.

By default, the “debug” feature is set to false in any WordPress installation. To enable WP_DEBUG, set it to true.

First, move into your websites installation directory e.g /var/www/html/mysite.com and then open the wp-config.php file using your favorite text editor.

$ cd /var/www/html/mysite.com
$ sudo vim wp-config.php

Look for this line.

define( 'WP_DEBUG',  false );

and change it to

define( 'WP_DEBUG', true );
Enable Debug Mode in WordPress

Enable Debug Mode in WordPress

Save the file and close it.

Now debug mode has been triggered. If we reload the page that showed the error, we can see the detailed error information as shown in the following screenshot.

WordPress Error Information

WordPress Error Information

There are additional debug options that extend WP_DEBUG that are particularly useful for WordPress developers creating plugins or themes, or any other components. They are WP_DEBUG_LOG and WP_DEBUG_DISPLAY.

The WP_DEBUG_LOG option when set to true causes all errors to be saved to a debug.log log file inside the /wp-content/ directory by default. This is useful for later analysis or processing.

define( 'WP_DEBUG_LOG', true );

But you can specify a custom log file e.g /var/log/nginx/mysite.com_wp-errors.log:

define( 'WP_DEBUG_LOG', '/var/log/nginx/mysite.com_wp-errors.log' );

And WP_DEBUG_DISPLAY controls whether debug messages are shown inside the HTML of pages or not. By default, it is set to true. To disable it, set it to false.

define( 'WP_DEBUG_DISPLAY', false );

Enable Debug Mode in WordPress Using Plugin

If you are using shared hosting, you probably don’t have access to the server backend to edit your WordPress files in this case the wp-config.php file.

Or if you simply prefer to change settings from the admin dashboard, you can install and use a plugin called “Debug Bar” which allows you to easily enable/disable WP_DEBUG from admin dashboard with a single click on the Toolbar.

The killer feature of this plugin is that it is failsafe and clever, it automatically exits the WP_DEBUG mode in case of errors.

Reference: Debugging in WordPress.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.