In Magento 2.x, the full error display on frontend is disabled by default. This article shows different methods on how you can see the full error message in your Magento 2 website.
I have written another article on how to Enable/View Full Error Display on Magento 1.x. This one is a similar article for Magento 2.x.
Method 1: View full error from var/report folder
By default, you will see the following message if any Magento related error happens in your code.
There has been an error processing your request
Exception printing is disabled by default for security reasons.
Error log record number: 1216554711619
Note the error log record number in the above message, i.e. 1216554711619
.
The full error will be present in your Magento root and inside folder var/report
. Inside your-magento-root-folder/var/report
folder, you just have to search for the file with name of the error log record number present above in the error message displayed, i.e. 1216554711619
.
So, the error is in file var/report/1216554711619
.
Method 2: Rename pub/errors/local.xml.sample file
You can simply rename one XML file and then you can see the full error display on the browser itself.
- Go to your Magento2 root directory
- Then, go inside folder
pub/errors
- There, you will see a file named
local.xml.sample
- Rename it to
local.xml
, i.e. remove the “.sample” from the name of that file. - Refresh Cache from your Magento Admin (System -> Tools -> Cache Management).
That’s all. Now, you should be able to see the error on the browser itself when you browse your Magento2 website.
Note: This way of enabling to show error on frontend browser view is not recommended in the production environment. It’s only good for the development environment.
Method 3: Edit .htaccess file
You can edit .htaccess
file of your Magento2 website to:
- enable Magento’s developer mode
- enable PHP’s error display settings
Open your site’s .htaccess
file and write the following at the end of that file:
php_value display_errors on ## enable PHP's error display settings
php_value error_reporting -1 ## set error display to E_ALL
Now, open terminal/command-prompt and go to your Magento’s root directory.
cd /path/to/your/magento/directory
Then, run the following command to enable developer mode.
php bin/magento deploy:mode:set developer
You can check the current deploy mode with the following command:
php bin/magento deploy:mode:show
Clear Cache
php bin/magento cache:clean
That’s all. Now, you should be able to see the error on the browser itself when you browse your Magento website.
Note: This way of enabling to show error on frontend browser view is not recommended in the production environment. It’s only good for the development environment. When you go to production, i.e. when the site is live, then comment out the above lines of code from your
.htaccess
file.
Method 4: Edit app/bootstrap.php file
Although editing .htaccess
file is preferred one, I just want to show that you can edit PHP file as well to enable error display on your Magento site.
- Go to your Magento’s root directory.
- Open
app/bootstrap.php
file. - At the beginning of the file, you should see the following line of code:
#ini_set('display_errors', 1);
- Add the following to it:
b) Set PHP Error Reporting as E_ALL (i.e. Report all PHP errors)
c) Enable PHP error display
So, the above lines of code in app/bootstrap.php
file will be updated as follows:
error_reporting(E_ALL); # Set Error Reporting as E_ALL (Report all PHP errors)
ini_set('display_errors', 1); # Un-commenting this line to enable PHP error display
Now, open terminal/command-prompt and go to your Magento’s root directory.
cd /path/to/your/magento/directory
Then, run the following command to enable developer mode.
php bin/magento deploy:mode:set developer
You can check the current deploy mode with the following command:
php bin/magento deploy:mode:show
Clear Cache
php bin/magento cache:clean
That’s all. Now, you should be able to see the error on the browser itself when you browse your Magento2 website.
Note: Enabling Error Display on Frontend is only good for Development Environment. Undo your changes when you move to Production.
Hope this helps. Thanks.