Fix Library: Upgrades and compatibility

500 Error After Upgrading to Magento 2.4.9

Last updated:

What you see

After the upgrade the store or the admin shows a blank page or "500 Internal Server Error".

Quick answer

A 500 error is a PHP error that the visitor cannot see. The answer is in the logs: Magento's exception log or the web server error log. After an upgrade the usual causes are a skipped setup:upgrade, stale generated code, the wrong PHP version for the web server, or an extension that is not compatible yet.

What usually causes it?

  1. setup:upgrade not run, so the database and code do not match
  2. Old generated code or a failed compilation
  3. The web server runs a different PHP version from the command line
  4. An extension that does not support 2.4.9 or the new PHP version
  5. File permissions changed during the upgrade

How do you check it safely?

These checks only read information. Run them on staging first if you can, from the Magento root folder as the file system owner. Hosting setups differ, so paths and service names may need adjusting.

  1. Read the newest errors.
    tail -n 50 var/log/exception.log
    tail -n 50 var/log/system.log
  2. Check whether the database is up to date with the code.
    bin/magento setup:db:status
  3. Compare the command line PHP version with the version the web server uses (phpinfo page or host panel).
    php -v
  4. List modules, to spot an extension that should be disabled.
    bin/magento module:status

How do you fix it?

These steps change your store. Run them on staging first, with a backup of code and database.

  1. On staging, run the upgrade steps again in order.
    bin/magento maintenance:enable
    bin/magento setup:upgrade
    bin/magento setup:di:compile
    bin/magento setup:static-content:deploy -f
    bin/magento cache:flush
    bin/magento maintenance:disable
  2. If compilation fails, clear the generated code and compile again.
    rm -rf generated/code/* generated/metadata/*
    bin/magento setup:di:compile
  3. Set the web server to the PHP version that 2.4.9 supports, with the PHP extensions Magento needs.
  4. Update or temporarily disable an incompatible extension, then run setup:upgrade again.
    bin/magento module:disable Vendor_Module

When should you call an expert?

Call an expert if the logs point to core code, several extensions fail at once, or the live store is down.

Need it fixed today?

I can look at it with you. Book a 20 minute call, or if the store is down, see emergency Magento support.

FAQ

Common questions.

Why is the page blank instead of showing an error?

In production mode Magento hides errors from visitors on purpose. The details go to var/log and the web server error log.

Can I roll back the upgrade?

Yes, if you took a backup of code and database before upgrading. That is why upgrades should be done on staging first.

Rather have it fixed for you?

Send a few lines about the problem, or book a 20 minute call. You get an honest read and a fixed quote.

Book a 20 minute call Reply within a few hours, 7 days a week.