Help Needed: Mautic Offline After Switching to Redis for Session Management

My Mautic version is: 5.0.3
My PHP version is: 8.1
My Database type and version is: MariaDB 10.11.7
Other: Ubuntu 20.04, HestiaCP 1.8.11, nginx 1.25.3

Hi everyone,

After switching my session management to Redis (e.g. session.save_path redis), my Mautic site went offline, displaying the error “The site is currently offline due to encountering an error. If the problem persists, please contact the system administrator.

Here’s a snippet from the error log that seems relevant:

2024/02/09 12:31:37 [error] 1761486#1761486: *91425 FastCGI sent in stderr: "PHP message: PHP Warning: SessionHandler::read(): Redis connection not available in /---/public_html/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php on line 59PHP message: PHP Warning: session_start(): Failed to read session data: user (path: /home/---/tmp) in /---/public_html/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 185PHP message: PHP Warning: SessionHandler::read(): Redis connection not available in /---/public_html/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php on line 59PHP message: PHP Warning: session_start(): Failed to read session data: user (path: /home/---/tmp) in /---/public_html/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 185" while reading response header from upstream, client: 77.77.218.192, server: myserver.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php/php8.1-fpm-myserver.com.sock:", host: "myserver.com"

It seems like the PHP session handler is unable to connect to Redis, instead it’s trying to read session data from /tmp, which leads to fatal error. Redis server status is running fine, other sites on same server also running fine. The configuration for Mautic was updated according to the documentation, so I’m puzzled about what might be causing this issue.

Has anyone experienced a similar problem or could offer some advice on how to troubleshoot this? Any suggestions on how to properly configure Redis for session management in Mautic, or tips on what might be going wrong, would be greatly appreciated.

Thanks in advance for any help you can provide!

PS. I added this to my local.php and cleared cache with
php bin/console cache:clear --env=prod

        'cache_adapter' => 'mautic.cache.adapter.redis',
        'cache_prefix' => 'mautic_',
        'cache_lifetime' => 86400,
        'cache_adapter_redis' => [
            'dsn' => 'redis://localhost',
            'options' => [
                'dbindex' => 6,
                'lazy' => false,
                'persistent' => 0,
                'persistent_id' => null,
                'timeout' => 30,
                'read_timeout' => 0,
                'retry_interval' => 0,
            ],
        ],

Have you checked if redis available?

To test if the redis server is listening, from your host:
redis-cli PING

You should receive “PONG” as a reply.

If not, your redis server located at “localhost” on port 6379 with no authentication using database 6 isn’t available.

Thank you so much for your reply.

Redis works fine, I receive “Pong” and I have 4 other databases in use on same server (for Wordpress and Moodle). Server is power enough to have multiple redis databases and config seems fine.

I don’t use auth for redis.

If anything else crossed your mind please share with me.

I would check if the PHP redis extension is installed and loaded.

Once confirmed, I would then check the PHP configuration and force it to something like tcp://127.0.0.1:6379

Thank you Marcus

It’s definitely installed and working, since I already use redis for other projects.

# php -i | grep Redis
Redis Support => enabled
Redis Version => 6.0.2
Redis Sentinel Version => 1.0

session.save_path = "tcp://redis:6379"

I would suggest to avoid flip-flopping between end-points naming and stick to a convention.

Try this:
dig localhost

And then try that:
dig redis

If both aren’t returning the same answer, then you have a DNS issue.