skip to Main Content

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.

2

Answers


  1. 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'),
                ]
            ]
        ]
    ]
    
    Login or Signup to reply.
  2. 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'),
                ]
            ]
        ]
    ]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search