Troubleshooting

Debug errors in WordPress

Reviewed on 3 min read wordpress errores diagnostico

WordPress lets you configure debugging in wp-config.php. To investigate a failure on a public website, send the details to a private log and keep error output hidden.

Preferably run these tests on a staging copy. In production, do not show errors on screen: they can reveal paths, queries and internal data to any visitor.

Log errors without showing them

Create a log directory outside public_html, make sure PHP can write to it and apply 0600 permissions to the file where the system allows it. Temporarily add these lines to wp-config.php, replacing CPANEL_USUARIO. Place them before wp-settings.php is loaded, usually before the comment telling you to stop editing. If a constant already exists, change its value instead of declaring it a second time:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', '/home/CPANEL_USUARIO/logs/wordpress-debug.log');
@ini_set('display_errors', '0');

Do not use wp-content/debug.log on a public website unless the server explicitly blocks downloading it. Reproduce the failure once, note the time and keep the first error from that request with a few lines of context. Check that it contains no passwords, tokens or personal data before sharing extracts.

I see a blank screen

If the WordPress log does not capture the failure, temporarily enable PHP logging from cPanel and check the same time, or ask support to review it. Always keep display_errors disabled in production.

Disable and clean up

When you finish, restore the previous values of WP_DEBUG, WP_DEBUG_LOG and WP_DEBUG_DISPLAY, remove the temporary ini_set line and delete the file once it is no longer needed. Debugging must not stay active indefinitely in production.

If the expected entry does not appear

Check that you edited the wp-config.php used by that installation and that PHP can write to the chosen path. Use the boolean values true and false without quotes: the text 'false' is not the same as boolean false.

WP_DEBUG widens the error levels and may generate many notices that are not causing the failure. Relate the first relevant error to the request and its time. If there is a syntax error before WordPress loads these options, check the server's PHP log. The official debugging guide details the scope of each constant.

You may also find useful

Something wrong or out of date? Tell us and we will review it.