How to configure PHP Native session with redis managed database

I’m using PHP 7.2 and I’m unable to connect a Redis managed db instance.

in /etc/php/7.2/fpm/php.ini

session.save_handler = redis
; tried either :
session.save_path = "rediss://"
session.save_path = "tcp://"
session.save_path = "tls://"
session.save_path = "tls://"

Each time same kind of issue :

read error on connection

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

I believe that the last line with TLS and auth defined looks correct.

I’ve just created a new Redis cluster and tested this with one of my servers where I have PHP 7.4 installed.

First I updated the PHP sessions handler:

; Old value:
;session.save_handler = files
; New value:
session.save_handler = redis

Then defined the save path:

session.save_path = "tls://"

After that, I restarted PHP-FPM or your Apache webserver.

Another thing that you need to keep in mind is that you need to open port 25061 for outgoing TCP connections in case that you have a firewall.

If this still does not work I could suggest trying with PHP 7.4 instead of PHP 7.2 and also make sure that you have the php-redis module installed.

For more information you could follow this tutorial here:

Regards, Bobby