Finding Your Website’s Error Messages in cPanel

A blank white page, or a bare “500 Internal Server Error”, is the least helpful thing a website can show you. The real error message almost always exists. It is written to a log file instead of the screen, which is the right behaviour for a live site, because error messages can reveal file paths, database names and other details a visitor should never see. The trick is knowing where to look.

The Errors page

In cPanel, open Errors in the Metrics section. It shows the most recent entries in the web server’s error log for your main domain, newest first. This is where messages from the web server itself appear: files it could not read, permissions it refused, requests it blocked, and instructions in an .htaccess file that it did not understand.

A mistake in .htaccess is one of the most common causes of a sudden 500 error across a whole site, and the error log names the file and the instruction it could not make sense of.

PHP’s own error log

Errors raised by PHP code, which covers most problems with a content management system, a shop or a plugin, are not usually in that log. By default on our servers, PHP writes them to a file called error_log in the same directory as the script that was requested. For most pages that is the directory the site lives in, such as public_html, but a request to an admin area or to a script in a subfolder writes its own error_log in that folder instead.

Open the file in File Manager, or download it, and start from the bottom, since new entries are added at the end. Each entry gives the time, the type of error, and the file and line number where it happened. The folder name in that path is normally enough to identify which plugin, theme or module is responsible.

Three types of entry are worth recognising:

  • PHP Fatal error stopped the request. This is the one behind a blank page or a 500 error.
  • PHP Warning did not stop anything, but something went wrong and the code carried on regardless. Worth fixing, rarely urgent.
  • PHP Deprecated means the code uses something a future version of PHP will remove. It changes nothing today, but it is an early warning of what will break when the PHP version changes. Why an older PHP version is not automatically a security risk explains how to plan that change.

Keep the files under control

An error_log file that nobody reads can grow for years. A warning raised on every page load, multiplied by every visitor, can produce a file several gigabytes in size, which counts against your disk space and is too large to open comfortably. Once you have read an old log it is safe to delete it, and PHP creates a new one the next time there is something to record. If the same warning keeps returning, it is the code that needs fixing, not the log.

Showing errors on screen, briefly

When you are actively tracking down a problem, it can be quicker to see the error in the browser. In cPanel, Select PHP Version or MultiPHP INI Editor, depending on how the account is set up, lets you turn on display_errors. Do it only for as long as you need it, ideally on a staging copy rather than the live site, and turn it off again afterwards. An error message shown to you is also shown to anyone probing the site for weaknesses.

Access logs

Errors tell you what went wrong. The access log tells you what was being requested at the time, which is often the other half of the story. Raw Access in the Metrics section lets you download it. Matching the time of an error against the access log usually shows which page, and sometimes which visitor or bot, triggered it.

If an error still does not make sense, open a ticket and paste in the lines from the log. The exact text, with its file path and line number, saves a great deal of back and forth.