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
- Test on staging first - Never directly on production
- Upgrade step by step - Not from 2.3 to 2.4.6 at once
- Plan downtime - Inform customers in advance
- Monitor after upgrade - Check logs and performance
- 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.
Related articles
What is web hosting? Explanation for beginners
Discover what web hosting is and how it works. Complete explanation about servers, domains and different hosting types for beginners.
What is VPS Hosting?
VPS hosting explained: what is a Virtual Private Server, who is it suitable for and what are the advantages compared to shared hosting?
What is an SSL Certificate?
Everything about SSL certificates: what is SSL, why do you need it and how do you recognize a secure website? Essential for every website.
What is Uptime in Web Hosting?
What does uptime mean in web hosting? Learn about uptime percentages, SLA guarantees and why 99.9% uptime is important for your website.
How much storage do I need for my website?
Discover how much disk space you really need for your website. Practical guide with examples per website type.