Call to undefined function mcrypt_module_open

Call to undefined function mcrypt_module_open

July 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Call to undefined function mcrypt_module_open

Solving the “Call to undefined function mcrypt_module_open()” Error in Magento

When working with Magento on PHP 7.1, you might encounter the dreaded Fatal error: Uncaught Error: Call to undefined function mcrypt_module_open() issue. This usually happens because Magento is looking for the old MCrypt library, which has been deprecated since PHP 7.2 and removed in PHP 8.0.

Understanding the Background

MCrypt was a popular encryption library used by many PHP applications, including early versions of Magento. However, it suffered from serious security vulnerabilities and was eventually dropped from the core PHP distribution.

Verifying MCrypt Installation

You mentioned that you’ve already installed mcrypt using sudo apt-get install mcrypt php7.1-mcrypt. Great! Let’s confirm this installation is correct by running php -i | grep mcrypt.

If everything is set up properly, you should see output similar to the following:

mcrypt

mcrypt support => enabled
mcrypt_filter support => enabled
Version => 2.5.8
Api No => 20021217
Supported ciphers => cast-128 gost rijndael-128 twofish arcfour cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes
Supported modes => cbc cfb ctr ecb ncfb nofb ofb stream

Directive => Local Value => Master Value
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

If you don’t see this output, or if it shows that MCrypt is disabled, double-check your installation steps.

The Core Issue: Magento Expects MCrypt

The problem lies in the fact that Magento core files still reference the mcrypt library that has been removed. When PHP looks for these functions and can’t find them, it throws an error.

Temporary Fix: Disabling the Required Files

While we wait for a proper patch from Magento or an upgrade to a newer version that doesn’t rely on MCrypt, you can temporarily disable the problematic files using an .htaccess or your server’s configuration file.

Add the following lines to your .htaccess file located in your Magento root directory:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Disable Varien_Crypt_Mcrypt.php for PHP 7.1+
    <FilesMatch "Varien/Crypt/Mcrypt\.php$">
        Order allow,deny
        Deny from all
    </FilesMatch>
</IfModule>

Don’t forget to restart your Apache server after making these changes.

A Permanent Solution: Upgrade Magento

The best way forward is to upgrade your Magento version to a recent release that doesn’t rely on MCrypt. This could be Magento 2 or the latest version of your current platform.

For example, if you’re using Magento 1, consider upgrading to Magento 2, which uses the OpenSSL library for encryption instead of MCrypt.

Conclusion

Dealing with deprecated libraries and old code can be challenging, especially when working on established platforms like Magento. Always keep an eye out for updates and security patches to avoid compatibility issues in the future.

If you’re looking for professional help in managing your Magento store or migrating to a newer version, consider reaching out to Laravel Company. We specialize in Magento development and e-commerce solutions tailored to your business needs.

Remember, while the temporary fix above is quick and easy, it’s crucial to plan a long-term strategy for keeping your platform secure and up-to-date.

Security API Extensions Errors

Our network