Magento Customer Retention Extensions
How To
Magento Customer Retention Extensions

How to enable error reporting in Magento 2.x

Does your Magento store shows a blank white page, a blank page with a error number, 500 Internal Server or broken content with missing footer?

Magento will display error message differently base on if your server is in production or developer mode. If your are debugging an issue on a none production server, you should considering switching your Magento store to developer mode.

Magento Display Blank White Page

If you are getting a blank white page in Magento, this is mostly cause by a fatal php error that php can not recover from and for security reason most server are configure by default to hide the error message because it may contain sensitive information.

The quickest way to debug a blank page error is to figure out what actually causing the issue by

  1. Checking your php error / apache error logs by connecting to your server via sshing, ftping, use cPanel file manager or open a support ticket with your hosting company to see how to get access to your error log files

  2. If you do not have access to your server error or don’t know the location, you can force php to print the error message to your browser by editing your index.php

 error_reporting(E_ALL);
 ini_set('display_errors', 1);

Eg. index.php

 <?php
 ...
  error_reporting(E_ALL);
  ini_set('display_errors', 1);
 
 try {
     require __DIR__ . '/app/bootstrap.php';
 } catch (\Exception $e) {
...

To prevent sensitive information from display to your user, you can hard code your ip address to only display the error message to your ip address.

 ...
 ipAddress = [
    'your public ip address here'
 ];
 
 if (in_array($_SERVER["REMOTE_ADDR"], ipAddress) {
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
 }
 ...

Magento Display Blank White Page with Error Message (There has been an error processing your request)

Ssh into into your web server, then navigate to your Magento2 root folder/var/report then view the file name refer in the error message.

This type of error normally happen when php encounter an error while outputting the content of the page that force php to stop.

To debug view your browser page source, then scroll to the bottom of the page and check for any error information. If not error is present then enable error reporting and try again.

Debug Steps

  1. Check php error / apache / NGINX error log files in the /var/log/ folder
  2. Check your Magento 2 error folder in Magento root var folder (var/report/*, var/log/debug.log, var/exception.log and system.log)
  3. Check your Magento mode (default, developer or production)
  4. Check your server php error log setting
Related

Magento 2 Extensions

Get more from your Magento2 store!

Enhanced Success Page

Add cross-sell, upsell, related products, social media links and other elements to your order confirmation.

HTML Minifier for Magento2

Minification is the process of removing all unnecessary characters and spacing from your source code without changing its functionality.

Magento Enhanced E-commerce

If your are using Magento + Google Analytics, then you need Enhanced E-commerce for Google Tag Manager.