How to Check Your Website’s Error Log


Sometimes you may experience issues with your website. Cases like a blank white screen or “500 Internal Server Error” do not say much. This tutorial will show you how to find PHP error log file and troubleshoot your website for errors. This is useful for both beginners and advanced developers, as it will provide with a specific line of your code that should be checked to resolve the issue. It also opens up more possibilities, such as using search engines like Google to look for a possible fix. This may be exactly what you need when you are stuck or have no idea where to start.

What you’ll need

Before you begin this guide you’ll need the following:

  • Access to your hosting account’s control panel

Step 1 — Enabling Error Logging

First of all, you should check whether error logging is enabled on your account by [checking the PHP information.]({{ site.baseurl }}{% post_url 2016-12-21-how-to-create-phpinfo-file-and-check-php-information %}) A quick way to check is to press CTRL+F and search for log_errors value.

log-errors in phpinfo

If the log_errors value is set to Off, there are a few ways to turn it on depending on your hosting platform.

Using .htaccess to enable log_errors

An easy and reliable way of managing the PHP configuration to use the .htaccess file. In case you do not know how to locate or find it, you can check [this tutorial.]({{ site.baseurl }}{% post_url 2016-06-01-how-to-locate-htaccess-file-on-cpanel-file-manager %}). To turn on error logging, the following line will need to be present in your .htaccess:

php_flag log_errors on

Next, we will need to set up a place for the errors to be logged. For this tutorial, we have created a file called error_log.txt in the public_html directory. For the errors to be saved there, the following lines were added to .htaccess:

php_value error_log /home/FTP_username/public_html/error_log.txt

enable log-erros in htaccess

Don’t forget to Save your changes. After that, re-check your PHP info and the log_errors value should be set to On. With this setup, the website’s errors will be logged in the error_log.txt file located in the public_html directory

Enabling log_errors in cPanel

If your host uses cPanel, navigate to your cPanel and click on Select PHP Version. Next, hit the Switch to PHP Options link.

Select PHP Version

Switch to PHP Options

If the log_errors option is set to off, simply change it to on. Do not forget to Save the changes and apply them by pressing Set as current button.

Enabling error_log

IMPORTANT! Your cPanel may be a bit different depending on the version, theme or hosting plan. In case you cannot find Select PHP Version section, consult with your hosting provider about modifying the PHP variables.

Step 2 — Opening the Error Log

From now on, when an error occurs on your website, an entry will be made in the error log. You may test if it works by adding an extra symbol in your code and refreshing the site. After that, use File Manager to open the error log file and check if there are any new entries:

error report in log

On cPanel platforms, the error log is located in your public_html directory and is named error_log by default. You can also open it using File Manager:

File Manager in cPanel

Open error_log

Step 3 — Understanding Error Log

While analyzing every possible error message is out of this tutorial’s scope, there are some guidelines in order to understand them better. The following are few examples of common errors:

  • Parse error: syntax error, unexpected T_PUBLIC in /home/username/public_html/cms/components/com_content/models/article.php on line 70 may mean that there is a syntax error in your code – you should check the mentioned file. Please note that line number is provided as well.
  • PHP Fatal error: Call to undefined function get_header() in /var/www/username/public/blog/wp-content/themes/theme/index.php on line 1 warns that index.php page is trying to call a function that does not exist. Check whether the function name is correct.
  • Fatal error: Maximum execution time of 30 seconds exceeded in /home/username/domains/ on line 737 could be resolved by modifying max_execution_time in your PHP settings.

Whatever the case might be, it is always a good practice to look up the error message on Google – it is likely other people have had this error message as well and perhaps resolved it. You may even learn a thing or two regardless whether you are a beginner or an advanced coder.


Now you know how to enable error reporting for your account, locate PHP error log file and troubleshoot it for errors. Error messages provide a lot of valuable information in order to get your website working again. Understanding errors will empower you to fix your site by yourself.

About the author

Merkys M.

Merkys is a server administrator and Linux expert at Hostinger. He keeps everything up & running while tackling advanced server management issues. Besides that, he’s a big fan of blockchain technology, web development, and bodybuilding.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in Website
How to Create phpinfo File and Check PHP Information
How to Create phpinfo File and Check PHP Information