How to Enable WordPress Debug Mode

Troubleshoot efficiently, enhance performance! Learn simple steps to enable WordPress Debug Mode on Cloudways. Start seamless debugging now!

Cloudways Product avatar
Written by Cloudways Product
Updated over a week ago

Table of Contents

Debugging in WordPress is fundamental to maintaining a smooth and error-free website. Whether you're an experienced developer or less familiar with website development, grasping how to use WordPress's built-in debug tools is critical to improving your troubleshooting skills. With Cloudways as your hosting platform, tapping into the capabilities of WordPress Debug Mode becomes straightforward.

In this guide, we'll take you through the easy steps to activate the WordPress Debug Mode, offering detailed insights into errors, warnings, and notices on your website. You can explore the ins and outs of efficient debugging to enhance your website's performance for a seamless user experience.

What is WordPress Debug Mode?

WordPress Debug Mode is a valuable tool designed to identify and address issues within the WordPress core, plugins, and themes. When your site encounters problems, enabling Debug Mode helps unveil the underlying PHP errors, notices, and warnings that might be causing unexpected behavior.

This mode proves especially beneficial in the complex ecosystem of WordPress, where themes, plugins, and databases interact intricately. Even minor errors can lead to site crashes, security vulnerabilities, or unexpected behavior. Debugging becomes necessary in catching these issues early in the development or maintenance phase, ensuring a seamless experience for website visitors.

When Should You Enable WordPress Debug Mode?

Debug Mode, when activated, provides a clear and organized presentation of information, revealing a spectrum of issues from code syntax problems to conflicts between plugins or themes. It empowers developers to pinpoint the root causes and take corrective measures efficiently.

However, it's crucial to note that Debug Mode is not recommended for use on live websites. Enabling it may expose sensitive information, making it primarily intended for testing and troubleshooting purposes. The debugging process, a routine in website development & maintenance, involves identifying and removing bugs or errors in the code before it reaches users. Developers utilize various strategies such as unit tests, code reviews, and pair programming to isolate and fix issues, ensuring a robust and error-free end product.

How to Enable WordPress Debug Mode

Before diving into the step-by-step guide to enable WordPress Debug Mode, it's crucial to understand the different methods available for activating this powerful feature.

For users comfortable with code, manually tweaking the wp-config.php file by connecting to your application using SSH or an SFTP client is a quick option. Alternatively, you can also install a WordPress plugin called WP Debugging.

Here's a quick explanation of all the PHP flags that will be used in this article:

Flag/Code

Explanation

define('WP_DEBUG', false);

This command sets the WordPress debug mode to "false," meaning it is turned off. When debug mode is off, PHP errors, warnings, and notices are not displayed on the website, making it suitable for live sites where you don't want users to see potential issues.

define('WP_DEBUG', true);

This command activates WordPress debug mode by setting it to "true." With debug mode on, PHP errors, warnings, and notices are displayed on the website, aiding developers in identifying and fixing issues during development or troubleshooting.

define('WP_DEBUG_DISPLAY', true);

This command, when added, allows errors to be displayed on the website. Errors are shown directly on the website, aiding in real-time debugging. However, it's crucial to disable this on live sites to avoid security and performance concerns.

define('WP_DEBUG_LOG', true);

This command, when added, logs errors in a file named debug.log. In addition to displaying errors on the website, this line saves a log file in the wp-content directory, providing a record of errors for later review. It's recommended to disable debug mode once issues are resolved.

Prerequisites

  • A basic understanding of SFTP (Secure File Transfer Protocol) and SSH (Secure Shell) is essential for accessing and editing files on Cloudways.

  • It is necessary if you understand the structure and content of the wp-config.php file, as it is where WordPress Debug Mode settings will be modified.

  • Please be aware of the risks associated with debugging, as enabling Debug Mode exposes detailed error information, including sensitive data.

Alternatively, you may also seek help from your web developer if you are uncomfortable handling this to ensure proper execution without compromising site security or functionality.

Important

We recommend taking an application backup before editing the wp-config.php file, which requires precision and care. Having a backup is a proactive measure to ensure your site's safety and integrity. You can also restore your application to a previous point if unforeseen issues arise.

First of all, please select your platform:

Cloudways Flexible

Step #1 — Connect to Your Application Remotely

First of all, connect to your application using SFTP or SSH. You can choose whichever method is best for you. Once you are connected to your application, you need to locate the wp-config.php file. This file is typically available in your application's webroot unless you have moved it due to security reasons.

SFTP

  1. First, go to applications > app_name > public_html and locate the wp-config.php file.

  2. Download and open the wp-config.php file with a text editor. Next, edit the file and add the code provided in step #2.

SSH

  1. First, type in the following command to locate the wp-config.php file.

    cd applications/app_name/public_html

  2. Next, you can just edit the file by running the following command and add the code provided in step #2.

    nano wp-config.php

Step #2 — Enabling Debug Mode

SFTP

  1. Find the line that says define('WP_DEBUG', false);.

  2. Replace false with true: define('WP_DEBUG', true);.

  3. Optionally, add the following lines to display all errors:

    define('WP_DEBUG_DISPLAY', true);
    define('WP_DEBUG_LOG', true);

  4. Save the changes and upload the modified wp-config.php file back to the server.

  5. Debug mode is now enabled. After completing the troubleshooting process, make sure to turn off the debug mode by setting WP_DEBUG to false and removing the additional code snippet. Leaving debug mode enabled could pose security risks to your site.

SSH

  1. Find the line define('WP_DEBUG', false);.

  2. Replace false with true: define('WP_DEBUG', true);.

  3. Add the following lines to the file for displaying all errors:

    define('WP_DEBUG_DISPLAY', true);
    define('WP_DEBUG_LOG', true);

  4. Save the changes (in nano, press Ctrl + O, then Enter, and Ctrl + X to exit).

  5. Debug mode is now active. To view errors, use a command like:

    cat wp-content/debug.log.

  6. After completing the troubleshooting process, make sure to turn off the debug mode by setting WP_DEBUG to false and removing the additional code snippet. Leaving debug mode enabled could pose security risks to your site.

Cloudways Autonomous

Step #1 — Connect to Your Application Remotely

First of all, connect to your application using SFTP or SSH. You can choose whichever method is best for you. Once you are connected to your application, you need to locate the wp-config.php file. This file is typically available in your application's webroot unless you have moved it due to security reasons.

SFTP

  1. Here, you will land in the public_html folder of your application where you need to locate the wp-config.php file.

  2. Download and open the wp-config.php file with a text editor. Next, edit the file and add the code provided in step #2.

SSH

  1. Here, you will land in the public_html folder of your application where your wp-config.php file is located.

  2. You can just edit the file by running the following command and add the code provided in step #2.

    nano wp-config.php

Step #2 — Enabling Debug Mode

SFTP

  1. Find the line that says define('WP_DEBUG', false);.

  2. Replace false with true: define('WP_DEBUG', true);.

  3. Optionally, add the following lines to display all errors:

    define('WP_DEBUG_DISPLAY', true);
    define('WP_DEBUG_LOG', true);

  4. Save the changes and upload the modified wp-config.php file back to the server.

  5. Debug mode is now enabled. After completing the troubleshooting process, make sure to turn off the debug mode by setting WP_DEBUG to false and removing the additional code snippet. Leaving debug mode enabled could pose security risks to your site.

SSH

  1. Find the line define('WP_DEBUG', false);.

  2. Replace false with true: define('WP_DEBUG', true);.

  3. Add the following lines to the file for displaying all errors:

    define('WP_DEBUG_DISPLAY', true);
    define('WP_DEBUG_LOG', true);

  4. Save the changes (in nano, press Ctrl + O, then Enter, and Ctrl + X to exit).

  5. Debug mode is now active. To view errors, use a command like:

    cat wp-content/debug.log.

  6. After completing the troubleshooting process, make sure to turn off the debug mode by setting WP_DEBUG to false and removing the additional code snippet. Leaving debug mode enabled could pose security risks to your site.

Tip

Additionally, you can also analyze logs on the Cloudways Platform, which can also be beneficial when it comes to debugging and troubleshooting application-level issues.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?