Getting errors on your site can be frustrating, especially when you're not sure what might be causing them. In the following article, we'll show you how to review your error logs to track down possible issues that are causing the error.
With SSH/Terminal Access
Troubleshooting via SSH is usually the quickest and easiest method. If you have SSH access, you'll want to begin here.
Viewing Recent PHP Errors
Connect to your site via SSH, then run the following command to view most recent PHP errors:
pagely error:php ~/sites/example.com
Viewing Errors As They Occur
Connect to your site via SSH, then run the following command to tail the error log live, as errors are occurring:
pagely error:php ~/sites/example.com --follow
Once you run the command, it will begin listening to any new errors that occur. If you reload the error page while this is running, you should see the error appear inside the terminal window.
With sFTP Access Only
Add the following code to the top of the wp-config.php file.
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
The error log will then be viewable in a browser at the http://example.com/wp-content/debug.log URL. The debug.log cannot be downloaded via SFTP.
When finished debugging:
- Comment or remove the lines added above to the wp-config.php file.
- The system will automatically remove the debug.log file for you shortly after so you don't need to worry about it.
- If you are concerned with leaving this available since it is publicly accessible you can delete the /wp-content/debug.log file through sFTP.
Bypassing Our Error Page
We cannot disable the error page, but you can bypass it to see what errors are popping up.
Add the following code to the top of the wp-config.php file:
if (false !== strpos($_SERVER['REQUEST_URI'], 'debug')) {
define('WP_DEBUG', true);
}
To view the error, add /?debug
to the end of the URL that's displaying the error.
For more on this topic: A Guide to Using WordPress Logs to Track Errors