1

I want to connect redis cluster from Laravel but I am getting No connections available in the pool. My databaase.php looks like

'redis' => [

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


    'clusters' => [
            'default' =>
                [
                  [
           
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB', '0'),
        ]],
        'options' => [
            'cluster' => 'redis', // This tells Redis Client lib to follow redirects (from cluster)

        ]
    ],

]

But with this settings, I am getting No connections available in the pool. But if I just connect redis cluster using cli, I can successfully connect. So I believe there is something wrong with my laravel configuration that I am still unable to solve. Any help?

Solution Hi guys, it was a configuration issue. I was using wrong port. The default port is 6379 and I was mistakenly using another port number.

Awais Qarni
  • 17,492
  • 24
  • 75
  • 137

2 Answers2

0

Moving the options to the parent array should solve your problem.

'redis' => [
    'client' => env('REDIS_CLIENT', 'predis'),

    'options' => [
        'cluster' => 'redis'
    ]

    'clusters' => [
        'default' => [
            [
                'host' => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', null),
                'port' => env('REDIS_PORT', '6379'),
                'database' => env('REDIS_DB', '0'),
            ]
        ]
    ]
]
Mathew Berry
  • 138
  • 1
  • 7
0

What about adding scheme and moving options ?

'redis' => [
    'client' => env('REDIS_CLIENT', 'predis'),

    'options' => [
        'cluster' => 'redis'
    ],

    'clusters' => [
        'default' => [
            [
                'scheme' => env('REDIS_SCHEME', 'tcp'),
                'host'   => env('REDIS_HOST', '127.0.0.1'),
                'password' => env('REDIS_PASSWORD', null),
                'port'   => env('REDIS_PORT', '6379'),
                'database' => env('REDIS_DB', '0'),
            ]
        ]
    ]
]
parastoo
  • 2,211
  • 2
  • 21
  • 38