Skip to content

Magento 2 upgrade guide: update safely

Last updated: 31 December 2025

Regularly updating Magento is essential for security and performance. But an upgrade can also cause problems if you're not careful. This guide teaches you how to upgrade safely.

Why upgrade?

Security:

  • Patches close vulnerabilities
  • Protection against known exploits

Performance:

  • Each version is faster
  • Improved caching

Features:

  • New functionality
  • Improved admin interface

Compatibility:

  • Extensions require newer versions
  • PHP version support

Preparation

Step 1: Check current version

bin/magento --version

Step 2: Check compatibility

Check for each extension:

  • Does the extension support the new Magento version?
  • Is an update available?
  • Are there known issues?

Step 3: Read release notes

Adobe publishes release notes with:

  • Breaking changes
  • Deprecated features
  • Known issues
  • Upgrade instructions

Step 4: Make backup

# Database
mysqldump -u user -p database > pre_upgrade_backup.sql

# Files
tar -czvf pre_upgrade_files.tar.gz /var/www/magento

# Or use n98-magerun2
n98-magerun2 db:dump --compression=gzip

Execute upgrade

Via Composer (recommended)

# 1. Maintenance mode
bin/magento maintenance:enable

# 2. Backup composer files
cp composer.json composer.json.backup
cp composer.lock composer.lock.backup

# 3. Update Magento
composer require-commerce magento/product-community-edition=2.4.x --no-update
composer update

# 4. Clear generated files
rm -rf generated/code/* generated/metadata/*
rm -rf var/cache/* var/page_cache/* var/view_preprocessed/*

# 5. Upgrade database
bin/magento setup:upgrade

# 6. Compile DI
bin/magento setup:di:compile

# 7. Deploy static content
bin/magento setup:static-content:deploy -f

# 8. Reindex
bin/magento indexer:reindex

# 9. Maintenance mode off
bin/magento maintenance:disable

Installing security patches

For security patches only without full upgrade:

composer require magento/product-community-edition=2.4.x-px --no-update
composer update
bin/magento setup:upgrade

Troubleshooting

"Allowed memory size exhausted"

# Increase PHP memory limit
php -d memory_limit=4G bin/magento setup:upgrade

Composer dependency conflicts

# Clear composer cache
composer clear-cache

# Update with ignore
composer update --ignore-platform-reqs

Extension incompatibility

# Disable problematic extension
bin/magento module:disable Vendor_Module

# Re-enable after upgrade
bin/magento module:enable Vendor_Module

White screen after upgrade

# Check logs
tail -f var/log/system.log
tail -f var/log/exception.log

# Clear cache
rm -rf var/cache/* var/page_cache/*
bin/magento cache:flush

Upgrade checklist

Step Status
Database backup made ☐
Files backup made ☐
Extensions compatibility checked ☐
Release notes read ☐
Staging environment tested ☐
Maintenance mode on ☐
Composer update executed ☐
Setup upgrade ran ☐
Static content deployed ☐
Functionality tested ☐
Performance tested ☐
Maintenance mode off ☐

Best practices

  1. Test on staging first - Never directly on production
  2. Upgrade step by step - Not from 2.3 to 2.4.6 at once
  3. Plan downtime - Inform customers in advance
  4. Monitor after upgrade - Check logs and performance
  5. Rollback plan ready - Know how to revert

When to hire a professional?

Do it yourself if:

  • Small shop with few extensions
  • Technical knowledge present
  • Minor version upgrade (2.4.5 → 2.4.6)

Get help if:

  • Large shop with significant revenue
  • Lots of custom code
  • Major version upgrade
  • No technical knowledge available

Was this article helpful?

Compare hosting packages directly to find the best choice for your situation.