The Ultimate Guide to Upgrade Magento 2

Magento 2 is the eCommerce software and platform that is trusted by the world’s leading brands. The undeniable benefits of Magento 2 (Adobe Commerce) make it a preferred eCommerce platform. Some typical benefits that should be named are a quality extension ecosystem and highly-supported eCommerce features.

The post is researched by Mageplaza’s specialists to guide the user how to upgrade Magento 2 version when using the command line & composer. Let’s follow this guide step by step.

Looking for
Upgrade Services?

Upgrade your Magento 2 store to the latest version for new features and security - with the help of our dedicated experts.

Upgrade now
upgrade service

4 Steps to update Magento 2

Step 1: Backup your store

Creating backups for your Magento 2 site is so urgent and necessary that you can protect all data from the disappearance through Backup Management if there is any change or break on the site. Follow this guide to backup your Magento 2 store.

Step 2: Turn on maintenance mode

You should put your store in maintenance mode while upgrading. To enable maintenance mode:

php bin/magento maintenance:enable

It will create a new file var/.maintenance.flag. If you cannot disable maintenance mode, you can remove this file [Remmember!]

Step 3: Upgrade to Magento 2

In this case, I will upgrade to Magento version 2.2.1. See latest releases at Download page, Github releases

Step 3.1 Pull package

Using the following command on terminal/command-prompt firstly:

composer require magento/product-community-edition 2.2.1 --no-update
composer update

You may be asked for username and password like this:

authentication keys To generate Public/Private Key pair please read this

Step 3.2 Flush cache

Now time to remove cache, generation. Run the following command line at root folder:

rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*
  • You may install Memcached, Redis cache…, you should flush those caches manually.

Step 3.3 Run Upgrade Magento

Run upgrade module, database schema

php bin/magento setup:upgrade

Step 3.4 Run complie, reindex

You should run compile and reindex for better performance after upgrading.

php bin/magento setup:di:compile
php bin/magento indexer:reindex
  • In Ubuntu/Debian Linux, when you meet the permission issues, remember to insert sudo at the beginning of every command like sudo composer update.

Step 3.5 Disable maintenance mode

You have turn on maintenance mode in the step 2, now you have to turn it off. Run the following command line to turn it off:

php bin/magento maintenance:disable

Step 4: Check the current Magento 2’s version

Next, you can check the Magento 2’s version by running the command.

php bin/magento --version

If the system show the cache write permission error, please add the following command to give write permission to pub and var directories:

chmod -R 777 pub var


Q: I cannot access to frontend after upgrading?

You may got this message: We're sorry, an error has occurred while generating this email.


That is because of read-write perrmissions for the web server. Run the following command to resolve it:

 find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; && find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; && chmod u+x bin/magento

Flush cache again:

rm -rf var/cache/*
rm -rf var/page_cache/*
rm -rf var/generation/*

Upgrade Magento 2 Service

Finding it too complicated?

Don’t worry; our upgrade experts are always here to help you upgrade to the latest Magento versions. With nearly 10 years in the Magento industry, we’ve helped hundreds of thousands of clients boost their performance, improve security, and rocket sales with the upgrade service. By relying on us, you can ensure the process is successful, while spending time on other essential business aspects.

Contact us for free consultations right now!


Enjoyed the tutorial? Spread it to your friends!


Sam Thomas
Sam Thomas

CEO and Founder of Mageplaza. Pursueing a simple and healthy lifestyle. A friend, a husband and a dad of two children, a trainer and an influencer wannabe. He is a big fan of sports and travel, also.

People also searched for

  • magento 2 upgrade update via command line composer
  • magento 2 upgrade composer
  • magento 2 module:upgrade command
  • upgrade magento 2 command line
  • magento 2.1 upgrade
  • magento 2 upgrade command
  • magento 2.1.2 upgrade
  • magento 2 update
  • magento 2 upgrade
  • magento 2 system upgrade
  • magento 2 update via command line
  • upgrade update via command line in magento 2
  • update via command line in magento 2
  • magento 2 version upgrade
  • how to upgrade magento 2 to latest version
  • update magento 2 to latest version
  • 2.2.x, 2.3.x, 2.4.x