How fix Exception Printing is Disabled by Default for Security Reasons in Magento 2

When working with Magento 2, you may sometimes see the error message “Exception Printing is Disabled by Default for Security Reasons“. First, I need to clarify that this is not  bug/error message, this is just notification from Magento 2 system to tell you that Exception Printing is currently disabled on your system (This is for security reason, the full error message is hidden to prevent system exploit). The error message looks like this:

Exception Printing is Disabled by Default for Security Reasons

Now we will make Magento 2 display real error message to know what error occurs on our website.

How to Enable Exception Printing in Magento 2

To enable Exception Printing in Magento 2, first, you need to open your server file manager.

If you are using a shared hosting, you can use File manager integrated within Cpanel or Directadmin


If you are using VPS/Dedicated server, you can use SFTP/FTP client like Winscp or Filezilla to access files on your server.

Now locate to pub/errors/local.xml.sample  and rename the file local.xml.sample to local.xml

rename localxml

After you finish, refresh the error page. Now you should see a clear error message instead of Exception Printing is Disabled by Default for Security Reasons

error message debug

For more detailed report, you can navigate to var/report/ and find Error log record number file.

If you have access to SSH, you can also use this command to enable developer mode to display error in detail

Flush cache and refresh page to see the error.

Common error and Solution

Database information changed

If you see the follwong error message in Var/report/, probably your database information was changed due to software update.

To fix this, go to /app/etc/env.php and make sure Database connection information is correct

Double check and refresh your site to see if we fixed it.

Wrong file permission

The following error message tells you that your Magento 2 folder is running under wrong permission.

To fix this, you need to give root permissions to your magento 2 instance , go to Magento 2 root path on SSH and enter the following code to give right permission to Magento 2 instance

Modules are outdated

You will see the follow messages if you didn’t upgrade your database after installing/deleting Magento 2 plugins

To fix this, simply run the command as suggested in the error debug. Go to Magento 2 CLI and run

After you finish, remember to flush cache. If the error still not goes away, check app/etc/modules/config.php and manually delete the modules listed in error messages.

Corrupt database

Sometimes, the error happens due to corrupted database. If you see this message:

Execute the follow command in your Magento2 database

Session issue

The following message is displayed if you did not specify session save path for Magento 2

To fix this, open etc/php.ini and edit:


Replace with:

Next, open php.env file and look for lines:

Replace with:

Now refresh page to see if the error is fixed


There’re a lot of error type after you enable Exception Printing and read debug log files. If you don’t find solution in my article, please drop a line with detailed Log message and I will try my best to help you fix it.

The following two tabs change content below.

Hung Tran

I'm a computer geek who has experience working with Magento and Magento 2. I help my client build website in Magento and test different types of hosting and module for Magento.

1 thought on “How fix Exception Printing is Disabled by Default for Security Reasons in Magento 2”

  1. Thank you for the guide, I found out that database information changed was changed on my Magento 2 website. After changing to correct info and clear cache, my site works normally again

Leave a Comment