How to configure Laravel 5.7 with Redis TLS (Using phpredis)


I’m using laravel 5.7 with phpredis (PHP 7.2), but I’m not able to get it to work with tls, I am trying to use it with digitalocean Redis managed database which only supports tls connections.

Any idea if tls even supported with laravel/phpredis?


Hi. Struggling from similar issue.

Got this using phpredis (latest version from pecl):

In PhpRedisConnector.php line 80:
  read error on connection to XXXXXX

And this using predis:

laravel.ERROR: Error while reading line from the server. {"exception":"[object] (Predis\\Connection\\ConnectionException(code: 0): Error while reading line from the server. [tcp://] at vendor/predis/predis/src/Connection/AbstractConnection.php:155)
#0 vendor/predis/predis/src/Connection/StreamConnection.php(314): Predis\\Connection\\AbstractConnection->onConnectionError('Error while rea...')
#1 vendor/predis/predis/src/Connection/AbstractConnection.php(120): Predis\\Connection\\StreamConnection->read()
#2 vendor/predis/predis/src/Connection/AbstractConnection.php(112): Predis\\Connection\\AbstractConnection->readResponse(Object(Predis\\Command\\RawCommand))
#3 vendor/predis/predis/src/Connection/StreamConnection.php(260): Predis\\Connection\\AbstractConnection->executeCommand(Object(Predis\\Command\\RawCommand))
#4 vendor/predis/predis/src/Connection/AbstractConnection.php(180): Predis\\Connection\\StreamConnection->connect()
#5 vendor/predis/predis/src/Connection/StreamConnection.php(288): Predis\\Connection\\AbstractConnection->getResource()
\6 vendor/predis/predis/src/Connection/StreamConnection.php(394): Predis\\Connection\\StreamConnection->write('*6\

Database config:

'redis' => [

        'client' => 'phpredis',
        'cluster' => false,

        'default' => [
            'host' => env('REDIS_HOST', ''),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
            'read_timeout' => 60,
            'timeout' => 5,
            'persistent' => false,


OS: Ubuntu 18.04 Laravel: 5.8.35

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

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.

Accepted Answer

So I managed to get this to work, basically the current phpredis version that is shipped with php 7.2 (Ubuntu 18) is old and does not support tls, to fix this I had to update phpredis from pecl (


I’ve created a step by step guide on how to do that along with a short video demo for anyone who is experiencing the same issue:

Hope that this helps! Regards, Bobby