How to Enable Debugging in WordPress

With Servebolt you will already have access to PHP error logs. Sometimes this isn’t enough and here is where WordPress’ own debug system comes in handy. In addition, this tool does not only need to be used for debugging, but it can be used to clean up code ensuring overall quality for your WordPress site.

Where to find your WP config file

To enable debugging we first need to edit your wp-config.php file. The easiest way to continue would be to log into the server with SSH. Here you have the availability to use built-in text editors like nano or vim making this a quick and easy process.

#Navigate to your web root
cd ~/public

#Edit your wp-config.php file
nano wp-config.php

We do have help articles on how to connect with SSH for both Mac and Windows here. If you wish to use SFTP, then the process would first be to download your wp-config.php file, the lines are shown below with a local text editor, and lastly upload the modified file again. Info on how to connect with SFTP can be found here.

Enabling WordPress debugging: What to add to your WP config file

Add the following lines of code at the bottom of your file but above the line /* That's all, stop editing! Happy publishing. */

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Image showing wp-config.php with nano editor
  • WP_DEBUG is what enables the debug mode. It is recommended to change the second parameter to false when you are not using the debug mode.
  • WP_DEBUG_LOG generates a debug.log file in your /wp-content/ directory. This is a great way to see the entire log of errors.
  • WP_DEBUG_DISPLAY is turned off by default as this will show error codes on your site. This is a great way to debug each page individually but should be turned off when your site is live. This option is best used for staging or development sites.

Now you are ready to test out your site functionality and whenever you find anything that does not work as intended, an error message should show up in wp-content/debug.log. In addition, we also offer other tools like WP Profile and WP Doctor. These help you check for potential performance issues and general faults with your WP installation.

If you have any additional questions or need extra help, please contact our support chat and we’ll be happy to help!