How To Upgrade Magento 2 To Latest Version?

Post by|Magento15 September,2020
2132 View

If you are running your eCommerce store in Magento, it is essential to keep an updated version of Magento for the new features and security purposes.

Today, I will share the steps to upgrade the Magento version and fix errors while updating Magento.

There were three ways to upgrade Magento

1.  Using the Composer from the command line
2. Using Web Setup Wizard from admin
3. Download latest Magento and replace the core files

Since the release of Magento 2.4.0, Magento removed the Web Setup Wizard from the admin panel. So, developers have to update Magento from the command line or by file replacement. I will suggest the command line functionality. As there is no Web Setup Wizard option, so we will discuss only available options.

Using The Composer From The Command Line

Updating Magento using the composer is the first method of updating Magento. The first step in this process is to define the new Magento version using the composer. You can run the below command from the Magento root directory.

composer require magento/product-community-edition 2.4.0 –no-update

Once you’ve written the above command, you need to update Magento using the composer.

composer update

After running the composer update command, you can download all the updated modules from the Magento repository. Make sure that your system specification is compatible with the latest Magento version. If everything is as expected, then you will not face any issue while updating Magento. But you might face most common issues if your system is not up to date or any third party extension might create a problem.

Below are some known issues that you might face while updating Magento.

1) Undefined class constant PRE_COMMAND_RUN

If you are getting this error, that means your composer version is old, and you need to update your composer version. Run the below command to update the composer version.

composer self-update

2) Unknown downloader type: Available types: git, svn, fossil, hg, perforce, zip, rar, tar, gzip, xz, phar, file, path

This is also regarding the composer version if you have updated your composer version and are still getting this error, then backup your vendor folder and re-run the command.

3) magento/product-community-edition 2.3.4 requires magento/magento2-base 2.3.4 -> satisfiable by magento/magento2-base[2.3.4]

The one mentioned above is a standard error we face when we upgrade Magento 2.2.x or below to the latest Magento. There is also one other reason for this error, which is the module installed using the composer. Here you can again try by removing the vendor folder and try to update Magento.

Download Latest Magento And Replace The Core Files

Replacing the core files is not a recommended way to update Magento. But in some cases, when Magento has more third-party extensions and more customization, we have to choose this way. The process is straightforward. First, you need to take a backup of all Magento core folders, not only the “vendor” folder.

After taking backup of core folders, you need to download the latest Magento version and replace particular folders.

Once you have made all the above changes, you need to run setup upgrade and deploy commands.

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

And this is all that you need to do to update Magento. There are few things to consider before updating Magento.

1) Backup your site first
2) Backup your database because when you run the “setup upgrade” command after an upgrade, new fields in the table or some fields might wipe-out.
3) Check your theme and extensions are compatible with more recent versions of Magento.

Above, we saw the issues while upgrading Magento. Now we will discuss some known issues after upgrading the Magento.

1) Refused to execute inline script because it violates the following Content Security Policy directive

Magento introduced the new module called “Magento_CSP” With regards to the CSRF Protection. You need to allow access to all the CDN resources. You can create an XML file in your module on below path


Add the below code to your file. This example works for the google analytics URLs

<?xml version=”1.0″?>

<csp_whitelist xmlns:xsi=”” xsi:noNamespaceSchemaLocation=”urn:magento:module:Magento_Csp/etc/csp_whitelist.xsd”>


        <policy id=”script-src”>



                <value id=”google-analytics” type=”host”></value>





2) An exception comes-up while creating “Request.”

You might get this error while running the “Content Deploy” command with PHP 7.3. This issue comes when you are using Magento 2.3.x with PHP 7.3 and to overcome this issue you need to change in the following file


Change inline 426 from “continue” to “continue 2.”


Running an older version of Magento is not a good idea. Nowadays, it is necessary to be up to date. Upgrading Magento will provide you the latest security updates and advantage of new features and performance improvements.

Magento also requires the updated version of extensions and themes so you can take advantage of those as well. So, contact an experienced Magento Development Company that will fulfill your development needs hassle-free!


Will the extensions automatically update by running the composer update?

No, if you have installed an extension using the composer, then you have to define a new version for those extensions before running the composer update.

Do we need to upgrade the server configuration to update the Magento version?

No. You just need to make sure about the PHP version.

Speak Your Mind

Please enter your comment.
Please enter your name.