Get a Free Consultation

    Search for:

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

    Last Updated | December 7, 2023

    In Magento 2, Exception Printing is disabled by default for security reasons in a production environment. Instead, it presents a generic error message to users without revealing detailed information about the error. 

    Why Exception Printing is Disabled By Default:

    In Magento 2, the default configuration involves disabling Exception Printing for security reasons. Exception Printing, when enabled, provides detailed error messages that offer insights into the inner workings of the system. These messages often contain sensitive information such as file paths, database details, and code snippets. While these details are incredibly useful for developers and administrators during the debugging and development phases, they can pose significant security risks when exposed to potential attackers in a live production environment.

    The primary concern revolves around the potential exploitation of this information by malicious entities. When attackers gain access to intricate details about the system’s configuration and vulnerabilities through these error messages, they can exploit weaknesses to compromise the system’s security. For instance, knowledge of file paths or specific code snippets could aid attackers in crafting targeted attacks or finding entry points to execute malicious activities.

    Therefore, Magento adopts a security-first approach by disabling Exception Printing in production environments. This security measure aims to safeguard sensitive information from falling into the wrong hands and mitigates the risk of potential security breaches. Instead, in a production setting, Magento usually presents generic error messages to users, which do not reveal detailed system information. This approach aligns with industry best practices, emphasizing the importance of minimizing the exposure of sensitive data that could be exploited by attackers.

    Error Message:

    When exception printing is disabled and an error occurs, you will get the general error message on the front end as given below.

    There has been an error processing your request

    Exception printing is disabled by default for security reasons.

    Error log record number: 845156254512

    How to Enable Exception Printing

    In Magento 2, enabling or disabling Exception Printing involves adjusting specific settings, typically within the system configuration or by modifying configuration files. Here’s how you can enable or disable Exception Printing:

    Method 1: Using the Admin Panel

    1. Login to the Admin Panel: Log in to your Magento Admin Panel.

    2. Navigate to Developer Settings:

    • Go to Stores -> Configuration.
    • Under the Advanced section in the left sidebar, select Developer.

    3. Enable or Disable Developer Mode:

    • In the Developer section, locate the Developer Mode option.
    • Set Developer Mode to Yes to enable Exception Printing, which displays detailed error messages.
    • Set Developer Mode to No to disable Exception Printing, which shows generic error messages instead.

    4. Save Configuration Changes:

    • After making the changes, click on Save Config to apply the modifications.

    Note: The Above Option is only used when your Magento 2 application is in developer mode:

    Method 2: Using the Command Line

    If you have command-line access to your Magento installation, you can enable or disable Exception Printing using the command-line interface (CLI).

    To enable Exception Printing (Developer Mode):

    Using Command Line - 1

    To disable Exception Printing (Production Mode):

    Using Command Line - 2

    Method 3: Directly Editing Configuration Files

    You can also directly edit the Magento configuration files to change the mode.

    To enable Exception Printing (Developer Mode):

    Modify the env.php file located in the app/etc directory. Look for the line:

    Directly Editing Configuration Files - 1

    Ensure it’s set to ‘MAGE_MODE’ => ‘developer’,.

    To disable Exception Printing (Production Mode):

    Change the ‘MAGE_MODE’ value in env.php to ‘production’:

    Directly Editing Configuration Files - 2

    After modifying the configuration files, clear the Magento cache for the changes to take effect.

    Remember, enabling Exception Printing (Developer Mode) in a live production environment is not recommended due to the security risks associated with exposing detailed error messages. It’s crucial to switch back to Production Mode for security purposes once debugging or development tasks are complete.


    In this article, we have learned about exception printing and why Magento 2 disabled this by default. We have also learned how we can enable/disable exception printing In Magento 2.



    Certified Adobe Commerce Developer with 10 plus years of development experience and 7+ e-Commerce specific experience. Having good expertise in web development and Other e-Commerce platforms, especially in Magento. The skill set includes Magento Customization, Theme Implementation, Third Party Integrations, Server Management, and Other platform-specific areas.