How to implement Memcached in Magento v.2?

Follow this tutorial to easily implement Memcached in Magento 2:

  1. First make sure you Activate Memcached caching in your control panel. You will need those IP and port number
  2. Check the PHP version. PHP 5.6 or earlier would work. PHP 7 will not work with this tutorial.
  3. Edit /app/etc/env.php:
    1. Using ssh, go to the root of your Magento installation. Under the app/etc/ directory locate “env.php”. This file you need to edit.
    2. Locate this code string
      'session' =>
          array (
          'save' => 'files',
    3. Edit that to match the following:
      'session' =>
         array (
            'save' => 'memcache',
            'save_path' => 'tcp://'

    In this line you have to replace the IP address and port number with the Memcached details that you get in your control panel.

  4. Test if it works. Go to the root of Magento installation and clear the contents of the cache:
    rm -rf var/cache/* var/page_cache/* var/session/*
  5. Make a final test by loading your site in your browser. If your website shows up, the configuration is correct.
Updated on 8 March 2020

Was this article helpful?

Need support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact support

Couldn't find a solution?


Our specialists are available 24/7 to provide you with free support. Feel free to contact Joachim and his colleagues via e-mail or by phone.

Joachim Coessens Specialist Support