Skip to content
Home » News » Fixing “An error has happened during application run” in Magento 2

Fixing “An error has happened during application run” in Magento 2

Magento 2 is a powerful tool used for building online stores. However, sometimes certain errors do appear, and one of the most common is:

“An error has happened during application run. See exception log for details.”

This error usually happens after installing or updating Magento 2, but there might be other reasons as well. The message itself doesn’t explain much, so one needs to do some digging to find the real problem.

Why Does This Error Happen?

There are several reasons why you might see “An error has happened during application run” message:

  1. PHP Errors – If there are mistakes in the PHP code or missing PHP extensions, this error message can appear.
  2. Database Issues – If Magento can’t connect to the database properly, it might crash and show this message.
  3. Missing Files – Sometimes, not all required files are installed correctly.
  4. Conflicting Extensions – If you installed a new extension, it might not work well together with the ones you already have.
  5. Magento Compilation Problems – Magento needs to process and compile its files. If something goes wrong, it can cause errors.

How to Fix  “An error has happened during application run” in Magento 2?

Magento Error notice: An error has happened during application run.

Since this error can have different causes, different solutions can be applicable. You may try the following one by one:

1. Check the Error Logs

Magento keeps records of everything that goes wrong in log files, which can be found in the var/log folder. You can check them here:

  • var/log/system.log
  • var/log/debug.log
  • var/log/exception.log
  • var/report/

A fuller and more detailed error message can be seen inside these files, which can help to understand the cause of the problem.

2. Turn on Developer Mode

Developer mode also helps to gather more details about errors, so you can understand them better. To turn it on, use this command:

php bin/magento deploy:mode:set developer

If you don’t have SSH access, you can change the .htaccess file instead. Open the file and find this line:

SetEnv MAGE_MODE developer

Remove the # at the beginning of the line (uncomment the line) to enable developer mode.

3. Update Magento and Compile Files

If Magento is missing some files or hasn’t been properly updated, run these commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f

These will make sure Magento has everything it needs to work properly.

4. Clear the Cache

Magento stores temporary data in its cache. Very often, just clearing the cache can fix the issue. Run this command:

php bin/magento cache:flush

After this, refresh your website and recheck if the error is gone.

5. Disable Problematic Extensions

If the error appeared right after installing a new extension, it might be the cause. You can disable it using this command:

php bin/magento module:disable VendorName_ModuleTitle
php bin/magento cache:flush

Replace VendorName_ModuleTitle with the actual name of the extension you want to disable.

6. Check Your Database Connection

Magento needs to connect to a database to work. Open the file app/etc/env.php and check if the database name, username, and password are correct. If any of these details are wrong, correct them and try again.

Conclusion

Magento 2 “An error has happened during application run” message can be frustrating, but it can be fixed by following the above steps. One should always check the error logs first, enable developer mode to obtain more details, and try clearing the cache or updating Magento. If the problem persists, it may be best to ask for help from a Magento expert. Fixing errors quickly is important so that your online store keeps running smoothly.

Author

Leave a Reply

Your email address will not be published. Required fields are marked *