Mautic shows "The Site is currently offline due to encountering an error" after upgrade from 4.4 to 5.1

Your software
My Mautic version is: 5.1.0
My PHP version is: 8.2 - tried 8.0 and 8.1 as well.
My Database type and version is: Mysql 5.7 and tried 8.0 as well
OS : Centos running cpanel. Tried on Alma Linux as well.
Your problem
My problem is: I have been running 4.4 version of Mautic for long time. Yesterday I tried to upgrade mautic to latest version using command line. It failed with Twig error, I then tried and executed the composer update command, but it didn’t help. I tried every possible solution mentioned on the internet but the issue persists. I am not able to run version 5.

These errors are showing in the log:
[2024-09-01T15:19:10.719222+00:00] mautic.CRITICAL: Exception thrown when handling an exception (Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template (“Mautic\CoreBundle\Twig\Extension\AssetExtension::getOverridableUrl(): Return value must be of type string, bool returned”). at /home/insightgenetic/public_html/app/bundles/CoreBundle/Resources/views/Default/head.html.twig line 10) {“exception”:“[object] (Twig\Error\RuntimeError(code: 0): An exception has been thrown during the rendering of a template ("Mautic\CoreBundle\Twig\Extension\AssetExtension::getOverridableUrl(): Return value must be of type string, bool returned"). at /home/insightgenetic/public_html/app/bundles/CoreBundle/Resources/views/Default/head.html.twig:10)\n[previous exception] [object] (TypeError(code: 0): Mautic\CoreBundle\Twig\Extension\AssetExtension::getOverridableUrl(): Return value must be of type string, bool returned at /home/insightgenetic/public_html/app/bundles/CoreBundle/Twig/Extension/AssetExtension.php:132)”} {“hostname”:" “,“pid”:1647}
[2024-09-01T15:19:10.728757+00:00] mautic.ERROR: Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template (“Mautic\CoreBundle\Twig\Extension\AssetExtension::getOverridableUrl(): Return value must be of type string, bool returned”). - in file /home/insightgenetic/public_html/app/bundles/CoreBundle/Resources/views/Default/head.html.twig - at line 10 {“hostname”:” ",“pid”:1647}

Steps I have tried to fix the problem:
Tried command line upgrade steps mentioned on the mautic page.
cleared cache couple of times, before and after upgrade.
deleted cache/prod directory and tried upgrading
ran composer update command with successfull message
Still problem persists.

Hi,
Did you install with composer originally?
J

No, as far as I remember initially installed Mautic using web, I have been using it for couple of years and I used to upgrade using web only.

Okay, that is a no-go.
You need to do it via command line.
Not web.
If you don’t have composer install that is also okay, but use the command line to upgrade

As I mentioned, I tried first using web and it failed.
I restored mautic using backups and tried command line, executing the command as mentioned on the mautic page : How to update Mautic — Mautic Documentation 0.1 documentation
But it failed.
I then tried composer steps and it failed as well.

Okay, let’s start from 0.
Which is the version you are upgrading from?

image
to 5.1.
Actually it only give me iption to upgrade to 5.1 when I execute the find command.

Hi,
So its a Mautic 4 → 5.1.
That is good.
What is the error you get when you upgrade via command line?