When working with Magento 2, sometime you will see the error: There has been an error processing your request – Exception printing is disabled by default for security reasons.
The error looks like this:
In this tutorial, we will find out how to force Magento 2 to display full error message and solution to fix each common error message
You may also look for: How to fix Magento 2 Error 503 Backend fetch failed with varnish cache
Cause of the error
In Magento 2, this error normally occurs when you install or upgrade extensions/themes on your site. The installation/upgrade probably caused conflicts on your site => Magento 2 throws that error message.
The error message There has been an error processing your request – Exception printing is disabled by default for security reasons is not a specific error of Magento 2, it only tells you that Exception Printing is currently disabled on your system.
Magento 2 does not show full error message because it will make your system vulnerable to hacker
How to display full error message
To display full error message for debug, follow these steps
Step 1: Find local.xml.sample file located in pub\error in Magento 2 website folder
You can access file on your server using File manager if you have Cpanel/Directadmin
If you’re using a VPS or dedicated server, you can use Winscp/Filezilla to manage file.
Step 2: Rename this file local.xml.sample => local.xml

Step 3: Reload your website to see full error message
If you’ve done step 2 correctly, now Magento 2 will show full error message instead of There has been an error processing your request – Exception printing is disabled by default for security reasons
Step 4: Enable Developer mode for enhanced debugging and to show errors right on frontend by using this command in ssh:
php bin/magento deploy:mode:set developer
Type of error message and solution
After turning on the debug, you will see various type of messages. Here I will list the most common errors and how to fix them
Unable to retrieve deployment version of static files from the file system.
This error happens because Magento 2 didn’t finish deploy static view files.
You can manually deploy static view files using this command:
php bin/magento setup:static-content:deploy
Flush cache and refresh your website, now the error should be fixed
php bin/magento cache:flush
Expecting a string, got NULL
This error may happen when you migrate data from Magento 1 to Magento 2, to fix this error run the following command in your ssh
php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f
SQLSTATE[HY000] [1045] Access denied for user
If you see the following error message => That means you are using wrong database information for your Magento 2 website
Exception #0 (Zend_Db_Adapter_Exception): SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) Exception #1 (PDOException): SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
To fix this error go to /app/etc/env.php and correct your database information
‘host’ => ‘localhost’, ‘dbname’ => ‘databasename’, ‘username’ => ‘database_username’, ‘password’ => ‘password_of_database’, ‘model’ => ‘mysql4’, ‘engine’ => ‘innodb’,
Replace: Databasename, database_username, password_of_database with your correct ones
Finally, flush cache and restart mysql to access your site
Wrong php version
If you see the following error message:
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /opt/lampp/apps/magento/htdocs/vendor/zendframework/zend-stdlib/src/ArrayObject.php on line 426
=> That means you are running a wrong PHP version for Magento 2
To fix this issue, first, check your phpversion using
php -v
Sample output
If you are running Magento 2.3, try to install php7.2
If you are running Magento 2.4, try to install php7.4 or at least php7.3
Search query throwing error
Whenever you search a query on your newly installed Magento 2 site, the result page throw the error like this
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.catalogsearch_fulltext_scope1' doesn't exist, query was: INSERT INTO `search_tmp_5eb592164ff260_69624311` SELECT `main_select`.`entity_id`, SUM(score) AS `relevance` FROM (SELECT DISTINCT `eav_index`.`entity_id`, (((0)) * 1 + LEAST((MATCH (data_index) AGAINST ('test*' IN BOOLEAN MODE)), 1000000) * POW(2, search_weight)) AS `score` FROM `catalog_product_index_eav` AS `eav_index`
INNER JOIN `catalogsearch_fulltext_scope1` AS `search_index` ON eav_index.entity_id = search_index.entity_id
This error sometimes happens because you have not reindex Magento 2 after making changes
Run the following command to reindex data
php bin/magento indexer:reindex
Warning: SessionHandler::read()
If you see this error
{"0":"Warning: SessionHandler::read(): open(var/www/html/var/session/sess_nloiac096cn9o6imqdkouoj96l, O_RDWR) failed: No such file or directory (2) in /var/www\$
You will see this error when session.save_handler PHP parameter is set to some another session storage than files (for example, redis, memcached, and so on). This is a known issue we're working to resolve.
This error occurs when session.save_handler PHP parameter not set to files session storage (for example session.save_handler is set to save to redis, memcached..)
To fix this issue we will setsession.save_handler to files storage
First, locate php.ini file on your server using the following command in ssh
php -i | grep "Loaded Configuration File"
Sample output
Here you can see that php.ini file is located in /etc/php/7.0/cli/php.ini, go to that path and edit php.ini, find the following lines:
session.save_handler = files
;session.save_path = "/tmp"
And change it to =>
session.save_handler = files
session.save_path = "var/www/your_magento2_folder/var/session"
Next, edit ./app/etc/env.php, find the following line
'session' =>
array (
'save' => 'files',
),
And change it to =>
'session' =>
array (
'save' => 'files',
'save_path' => '/var/www/magento2/var/session',
),
Conclusion
The errors I had mentioned in this tutorial are only some common errors. If you do not find the error you want to solve, please drop the error message, log (with screenshot if possible).
I will try my best to help you fix that error and also update the error/solution to this article.






