Free migrationUK web hosting from £2.99 a month, with backups every six hours and a 60-day money-back guarantee.UK web hosting from £2.99 a month.See hosting plans

How to turn on WordPress debug mode

On this page

This guide shows how to switch on WordPress debug mode so errors are written to a log file you can read, and how to switch it off again when you’re finished.

Why use debug mode

When something goes wrong, WordPress often shows a vague “critical error” message or a blank page. Debug mode records the actual PHP error, including the file and line number. That usually tells you which plugin or theme is at fault.

The safest way is to send errors to a log file and keep them hidden from visitors. Error messages can reveal file paths and other details you don’t want on public pages.

Edit wp-config.php

  1. Log in to cPanel. See how to log in to cPanel.
  2. Open File Manager and go to the folder your site is in, usually public_html.
  3. Right-click wp-config.php and choose Copy to make a backup, for example wp-config-backup.php.
  4. Right-click wp-config.php and choose Edit.
  5. Look for a line containing WP_DEBUG. It usually reads define( 'WP_DEBUG', false );.
  6. Replace that line with these four lines:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
  1. If there was no WP_DEBUG line, paste the four lines just above the comment that says “That’s all, stop editing!”.
  2. Click Save Changes.

Make sure each setting appears only once in the file. If WP_DEBUG_LOG or WP_DEBUG_DISPLAY is already defined further down, change those lines rather than adding a second copy, or WordPress will show a warning.

What each line does

  • WP_DEBUG turns debug mode on.
  • WP_DEBUG_LOG saves each error into a log file.
  • WP_DEBUG_DISPLAY set to false stops errors being printed on your pages.
  • The ini_set line tells PHP not to display errors either, as a second safeguard.

Find debug.log

  1. Load the page that has the problem, or repeat the action that fails, so the error is recorded.
  2. In File Manager, open wp-content.
  3. Look for a file called debug.log. Click Reload if it doesn’t appear straight away.
  4. Right-click it and choose View or Edit to read it.

The newest entries are at the bottom. Each one starts with a date and time, then the type of problem, such as “PHP Fatal error” or “PHP Warning”, then the file path. A path containing wp-content/plugins/plugin-name/ points to that plugin, and one containing wp-content/themes/theme-name/ points to the theme.

Fatal errors are the ones that break a site. Warnings and notices are often harmless and can be ignored while you look for the cause.

If the error points to a plugin and you can’t log in, see how to disable WordPress plugins without logging in.

Turn it off afterwards

Don’t leave debug mode running. The log file grows over time, and anyone who guesses its address may be able to read it.

  1. Edit wp-config.php again.
  2. Change WP_DEBUG back to false, or remove the four lines and put back define( 'WP_DEBUG', false );.
  3. Click Save Changes.
  4. Delete wp-content/debug.log, or download it first if you want to keep it for a developer.

Using WP Toolkit instead

Some versions of WP Toolkit include a Debugging option on the site’s card, with switches for the same settings. If you see it, it is a quick way to toggle debug mode without editing files. Check afterwards that the display option is off, so errors are not shown to visitors, and remember to switch it all back off when you’re done. If you can’t find the option, edit wp-config.php as above.

If it doesn’t work

  • No debug.log appears. The page may not be producing a PHP error, or WordPress can’t write to wp-content. Check the folder permissions are 755. The server’s own error log may also show the problem. See how to find error logs in cPanel.
  • The site broke after editing wp-config.php. A quote or semicolon is probably missing. Restore your backup copy and try again.
  • Errors still show on the page. Another plugin or php.ini setting may be forcing them on. Check you set WP_DEBUG_DISPLAY to false and that it isn’t defined twice.
  • The log mentions running out of memory. See how to increase the WordPress memory limit.

Still stuck? Open a support ticket and we’ll help.

Still stuck? Open a support ticket from your client area. Tell us your domain and which step went wrong, and we'll take it from there.
WordPress hosting from £2.99 a month

WP Toolkit, staging, backups every six hours and free migration of your site.

See WordPress hosting
Open in new tab