0

I am trying to use ElasticCache Redis Cluster(Cluster mode enabled not sentinel) on Laravel-5.4.32 but getting below error:

1/1) ServerException MOVED 13491 10.0.1.199:6379

My database.php looks like below:


'redis' => [

    'client' => 'predis',
    'cluster' => true,

    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => 0,
    ],

],

REDIS_HOST value is been provided using .env file. My application works fine with single redis instance.

Scuzzy
  • 12,186
  • 1
  • 46
  • 46
ramesh.mimit
  • 9,445
  • 4
  • 21
  • 23
  • I have already tried the configuration mentioned here: https://stackoverflow.com/questions/41091103/laravel-predis-redis-cluster-moved-no-connection-to-127-0-0-16379 It does not work for me. same error. – ramesh.mimit Aug 14 '17 at 03:45
  • Please see this post: PHP [demo code](https://stackoverflow.com/questions/45684076/cannot-connect-redis-cluster-in-elasticache-to-php-using-phpredis-library/51186536#51186536) using AWS ElastiCache Redis. – Frank Liu Jul 05 '18 at 11:39

1 Answers1

0

Below configuration worked for me:

'redis' => [
    'client' => 'predis',
    'options' => [
        'cluster' => 'redis',
    ],
    'clusters' => [
        'default' => [
            [
                'host' => env('REDIS_HOST', 'localhost'),
                'password' => env('REDIS_PASSWORD', null),
                'port' => env('REDIS_PORT', 6379),
                'database' => 0,
            ],
        ],
    ],
],

Actually, this is clearly mentioned in laravel documentation: https://laravel.com/docs/5.4/redis#configuration

ramesh.mimit
  • 9,445
  • 4
  • 21
  • 23