Troubleshooting WordPress: How to Enable Debug Mode
Debug mode is a special setting in WordPress that reveals detailed error messages and warnings that are typically hidden from view. These messages provide clues about what’s going wrong behind the scenes, helping you pinpoint and resolve any issues.
Why enable debug mode in WordPress?
Debug mode can reveal the root causes of errors, saving you the guesswork of trying to have to work out how and why they’re occurring.
When it comes to optimising the speed and performance of your website, debugging is a way to uncover bottlenecks and resource-intensive processes that might be slowing everything down.
Debug mode also gives you the chance to test out plugin and theme compatibility. It’s a smart way to see how new plugins and themes interact with your site and rat out any conflicts.
While debug mode is a powerful tool, it’s not meant to be left permanently enabled on a live site. The detailed error messages it displays could potentially reveal sensitive information to visitors. However, it’s perfectly safe to temporarily enable debug mode for troubleshooting purposes and disable it again afterwards.
In the next section, we’ll guide you through the simple steps to access and activate debug mode in your WordPress installation.
How do I enable debug mode in WordPress?
First, locate your wp-config.php file, typically found in the root directory of your WordPress installation. You can access it using an FTP client or your hosting provider’s file manager.
Next, open the wp-config.php file in a text editor and search for the line define(‘WP_DEBUG’, false);
Change false to true. Then, add the following code on the next line: define(‘WP_DEBUG_LOG’, true);
This will create a log file to store error messages instead of displaying them directly on your website.
After saving your changes to wp-config.php, visit your website in a browser. This will trigger WordPress to generate error logs. Once done, access the debug log file, named debug.log, which will be created in the /wp-content/ directory of your WordPress installation. Use your FTP client or file manager to access it.
Finally, open the debug.log file in a text editor. You’ll see detailed error messages, warnings, and notices. Take a careful look at these to identify the source of your issue. The file paths mentioned in the errors can help you pinpoint whether a plugin, theme, or core file is causing the problem.
Remember to turn debug mode off by changing WP_DEBUG and WP_DEBUG_LOG back to false in your wp-config.php file and delete the debug.log file once
For more information on what each PHP error means, please read our Support article:
Understanding WordPress related PHP errors
What is the WordPress database connection string?
The WordPress database connection string is a set of configuration values in the wp-config.php file. These values define how WordPress connects to its MySQL database.
Occasionally, issues like the “Error Establishing a Database Connection” message might arise. This suggests a problem with how WordPress connects to its database. If this happens, you may need to update the connection strings in your wp-config.php file.
How do I update my WordPress database connection string?
Start by connecting to your hosting using an FTP client such as FileZilla. For details on how to do this, please read our Support article:
How do I upload files using SFTP?
Once connected, locate the wp-config.php file, right-click on it, and select “Edit.” If prompted, choose a text editor like Notepad to open the file.
Inside the wp-config.php file, you’ll find lines defining your database name, username, password, and host. The section looks like this:
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘yourdatabasename‘);
/** MySQL database username */
define(‘DB_USER’, ‘yourusername‘);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘yourpassword‘);
/** MySQL hostname */
define(‘DB_HOST’, ‘yourhostname‘);
$table_prefix = ‘yourtableprefix‘;
Be sure to confirm that the information in this file matches your details:
yourdatabasename should match your MySQL Database Name
yourusername should match your MySQL Username
yourpassword should match your MySQL password
yourhostname should match your MySQL Host Name
yourtableprefix should match your Table Prefix
If any of the information within your wp-config.php file doesn’t match your database details, then update the file with the correct information. Save the updated file to confirm your changes. Be sure to check your website to make sure it’s back online.
Wrap Up
And that’s it! You’ve learned how to use debug mode in WordPress. Remember: Debug is only a sort of “detective mode” for fixing problems. When you’re done fixing things, be sure to turn it off again. The messages it shows could give away secret information about your website. So, be careful and only use debug mode when you need to. This way, you can keep your WordPress website running smoothly and safely.