Processing... Please wait...

Product was successfully added to your shopping cart.

How to Upgrade Magento 2.3 to 2.4 Tutorial (updated 2024)

Magento Upgrade Magento Upgrade

Today I will describe how you can upgrade Magento 2.3 to 2.4 (the latest version is 2.4.6-p3).

When you run an eCommerce store it is vital to stay secure and up to date. You should always look out for the latest M2 version and update promptly.

Running the latest platform version will help with improving performance and keeping hackers and skimmers away.

A word of advice: always backup your files and database before attempting an upgrade. With a platform as complex as Magento 2 you can’t anticipate what is going to happen next. A lot of things might go wrong. You better have a way to go back.

2 Ways to Upgrade Magento 2 Installation

  1. Magento composer update. That is using Composer, a terminal command line program.
  2. Copy the Magento 2 latest version over the old installation.

1. Using Composer

Composer is a dependency manager for PHP. It can help you update your store with minimum hassle.

Instructions to get Composer installed might depend on your server operating system. I will use Debian Linux as an example. Run this SSH command:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

It will install Composer systemwide for every user to run. You can always ask your system administrator for assistance.

Now for the upgrade itself you will need to use SSH (Secure Shell). Ask your hosting company for credentials. Login to your server and go to the Magento root folder (usually it is ~/public_html):

cd ~/public_html

Then remove everything in the vendor folder:

rm -rf vendor/*

Now you can open composer.json file and replace your current version with the latest version sequence (say 2.4.6-p3):

Set the latest Magento 2 version in composer.json Set the Latest Magento 2 Version in Composer.json

When that is done go to SSH and update Magento 2 with Composer:

composer update

It will ask you for credentials.You may obtain those at Magento marketplace, here is the link https://marketplace.magento.com/customer/accessKeys/:

Magento marketplace public/private keys Magento Marketplace Public/Private Keys

One thing to remember: username is a public key and password is a private key. That is one of the ways Magento might confuse you.

Once you enter credentials, Composer will go ahead and install the latest Magento 2 version:

Magento Composer Upgrade Magento Composer Upgrade

UPDATE: If you don't want to edit any files you can run the following command to update to the latest Magento release (2.4.6-p3 at the moment):

composer require magento/product-community-edition 2.4.6-p3 --no-update
composer update

If you are running Magento 2 commerce the command will be slightly different:

composer require magento/product-enterprise-edition 2.4.6-p3 --no-update
composer update

When it is completed, run another SSH command and upgrade the Magento database:

php bin/magento setup:upgrade

After that you will want to recompile if you are in production mode:

php bin/magento deploy:mode:set production

This is it. You’ve successfully upgraded the platform to the latest version! Now go to the frontend and backend and check everything.

NB: Composer might complain about some PHP extensions not being downloaded. You might want to install them in order to proceed.

2. Download the latest version manually and copy/paste

Upgrade this way if the previous two failed for whatever reason.

Download the latest Magento 2 from the official github page. Unzip it in your magento main folder. That will overwrite the core files with the new ones.

Then run:

php bin/magento setup:upgrade


php bin/magento deploy:mode:set production

That will upgrade database, compile and deploy static content. It might require some time depending on the number of products, orders and customers you have.

Upgrade is done. Head to frontend and backend and see if everything looks normal.

Should I update my theme after an upgrade?

If it’s a custom-made theme you should definitely contact its developers and ask them to audit it. Tell them you just upgraded M2 and you are not sure if the theme will play well with the current Magento version.

If you purchased a premade theme the vendor usually releases patches for every new M2 version that comes out. Go to templatemonster.com or the site you bought your theme from and see if there are updates available for download.

It is important that you check your Magento frontend pages for any misaligned or missing content. A new version can cause serious damage to the look of your website.

What if things go the wrong way?

As with everything in Magento, an upgrade is easier said than done. Below I put together the various errors (and suggested fixes) that might happen during the upgrade process.

1. Component dependency conflict

This problem happens when you try and upgrade Magento via Setup Wizard. At the Readiness Check step it might throw out an exception like this:

Component Dependency Conflict Component Dependency Conflict

There is no real explanation of the issue and you might wonder how to fix it. From my experience dependency conflict in most cases is caused by a third-party extension depending on some old Magento 2 component.

You can resolve the issue by doing the following:

  1. Uninstall all custom extensions.
  2. Perform an update to the latest Magento version.
  3. Reinstall the custom extensions.

In some cases the conflict is caused by a changed composer.json file. Try and restore composer.json to the original version and run Setup Wizard one more time.

2. Can’t create directory

This error happens when you run php bin/magento setup:upgrade right after an upgrade. The complete issue description might look like this:

Fatal error: Uncaught exception 
'MagentoFrameworkExceptionLocalizedException' with message 
'Can't create directory 
in /var/www/html/site/vendor/magento/framework/Code/Generator.php:103 
Stack trace: #0 /var/www/html/site/vendor/magento/framework/Code/Generator/Autoloader.php(35): 
#1 [internal function]: MagentoFrameworkCodeGeneratorAutoloader->load('MagentoFramewo...') 
#2 [internal function]: spl_autoload_call('MagentoFramewo...') 
#3 /var/www/html/site/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('MagentoFramewo...') 
#4 /var/www/html/site/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): MagentoFrameworkCodeReaderClassReader->getConstructor('MagentoFramewo...') 
#5 /var/www/html/site/vendor/magento/framework/ObjectMana in /var/www/html/site/vendor/magento/framework/Code/Generator.php on line 103`

What should you do in this case? The fix is very simple:

  1. Delete var/di folder.
  2. Change permissions of var and pub folder to 777 (chmod -R 777 var pub).
  3. Run php bin/magento setup:upgrade.
  4. Run php bin/magento setup:di:compile.

3. Cannot allocate memory error

If you encounter this error during an upgrade it means there is not enough RAM allocated to PHP processes. Contact your system administrator and ask him/her to increase memory limit to at least 2 Gs.

Of course that means you cannot safely run Magento 2 on a server with less than 2G of available RAM. You should upgrade your plan to meet the minimal hardware requirements.

4. There are no commands defined in the "setup" namespace

This is a generic message that might not be helpful.

There are various ways to try to fix the error:

1. Give full permission to var and pub folders:

sudo chmod -R 777 var pub

2. Inspect your custom modules, make sure every extension's module.xml has setup_version in it:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
  <module name="SomeVendor_SomeModule" setup_version="1.1.2"/> 

3. Inspect your composer.json file. Sometimes an error there might cause a command to throw the"no commands defined" exception.

5. php bin/magento setup:upgrade not working

From my experience this is mostly related to some custom module having a problem. Try to inspect every one of them to see if you could spot an error.

Try to delete every custom module, update your instance and install them back.

Sometimes clearing generated (the latest 2.2.x versions) or var/di, var/generation (in case of an older Magento 2.1 upgrade) folders helps.

Bonus: Can I downgrade Magento 2 the same way I upgrade?

Yes you can!

You should follow step 1 and downgrade with Composer. Just put the version number you would like to have and repeat everything else.

I have tried this method and successfully downgraded 2.1.8 to 2.1.6.

I don't think you can use the Web Setup Wizard, but I am sure you can follow step 3 to downgrade M2.

I hope now you have learned how to upgrade Magento 2 to the latest version. At least I hope I managed to explain it well in this article. If you have any questions you are more than welcome to ask them at the bottom of this page.

Do you know Magento 2 can be slow? And slow checkout leads to sloppy conversion rates.

Check these 30 ways to improve Magento 2 performance.

Contact an expert to make your Magento faster.

Do you need a Magento 2 update? Contact me today for a free quote!


If you find this post interesting do not hesitate to sign up for our newsletter and join the 1312 people who receive Magento news, tips and tricks regularly.

Thank You!


8 thoughts on “How to Upgrade Magento 2.3 to 2.4 Tutorial (updated 2024)”
  • Stella George December 24, 2020 at 9:29 am

    Great Article on Magento 2 Upgrade!

  • Sagar Chand May 11, 2020 at 6:01 am

    Nice! blog seems helpful, Guidance Makes update ease.......Mentioning conflicts were also assured error-free upgrade.

  • Sarah Marsters January 30, 2020 at 8:51 am

    Thanks for the useful article!

  • Gaurav Jerath March 22, 2019 at 2:58 am

    Written in a very detailed and organized manner. Apart from backing up the database, checking compatibility still remains the main issue in an upgrade. My recommendations:
    • Make a full backup of your Magento 1 store including all files, folders, and the database.
    • Create a clone of your Magento 1 store. Do not use the live store for Magento migration process.
    • Analyze your store. Keep what you think is necessary and delete the rest.
    • Check whether your current theme(s), extensions and custom code are compatible with the Magento 2.
    • Migrate the data from the cloned database of your Magento 1 store.
    • Remove outdated and useless data from the database. This includes logs, recently viewed products, compared products.
    • To make Magento migration process as hassle-free as possible, install a fresh copy of Magento 2 on the same hosting server where your Magento 1 store is located.

  • Damon Moats February 8, 2019 at 7:11 am

    Thanks for this guide for upgrading Magento, I wanted to upgrade my website because of a marketplace extension which I learned about on Magenticians, which is not compatible with my website. Thanks again

  • Miley Cyrus January 3, 2019 at 8:06 am

    Your article Awesome Thanks for this information, very informative as well as Modern.

  • seanmal July 8, 2018 at 1:48 am

    One can upgrade magento 2 using the two basic methods, one is from admin panel and other is using composer

  • markwarner September 26, 2017 at 12:42 am

    Good tips to upgrade the Magento! Many people want to upgrade their Magento with the higher version. After visiting this article, they can have a rough idea of upgrading their Magento versions! Looking to visit this article more often in the future!