Configuring Laravel with Redis TLS

Today I lost a few hours to debug the issue when I was trying to move a Laravel application to Digital Ocean.

I love Digital Ocean in the sense that it’s very user friendly, not overly complex like AWS, and fairly priced. I was eagerly waiting for the managed database to launch in Digital Ocean, which they added.

MySQL was working perfectly, but the problem occurred when I added the cache/queue server. I was scratching my head and searching all over. This is a very good resource for solving this problem.

I understood I’ve installed the Pecl Redis library as it is able to connect via TLS. Even though I’ve installed/updated the pecl extension, nothing was working.

I had checked multiple times, my configuration looks exactly like this:


I kept getting the error: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known [tcp://tls://

It was skipping my mind that we have to use the phpredis client in the Laravel config config/database.php, not the predis client.

'redis' => [
    'client' => 'predis',

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

After changing the client, everything worked perfectly.

Note: Older Laravel version defaults to predis. The newer version, however, defaults to phpredis and expects another env variable, REDIS_CLIENT. Predis may be removed from the framework soon due to lack of maintenance.

'client' => env('REDIS_CLIENT', 'phpredis'),

By Tareq Hasan

Hello, I'm Tareq. I am the founder of weDevs.

I love challenges and I am very passionate about web technologies. From Frontend to Design, from Backend to DevOps, I love playing with every aspect of it.

Leave a Reply

Your email address will not be published. Required fields are marked *