title: How to make Laravel work with Redis cluster on AWS
body: <p>I'm trying to use Laravel (5.4) with a clustered version of Redis. I followed the instructions form <a href="https://stackoverflow.com/questions/41091103/laravel-predis-redis-cluster-moved-no-connection-to-127-0-0-16379/41256321#41256321">this post</a> like so:</p>
  
  <pre><code>/*
  |--------------------------------------------------------------------------
  | Redis Databases
  |--------------------------------------------------------------------------
  |
  | Redis is an open source, fast, and advanced key-value store that also
  | provides a richer set of commands than a typical key-value systems
  | such as APC or Memcached. Laravel makes it easy to dig right in.
  |
   */
  
  'redis' =&gt; [
       'client' =&gt; 'predis',
       'cluster' =&gt; 'true',
  
       'default' =&gt; [
              'host' =&gt; env('REDIS_HOST_1', '127.0.0.1'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; 6379,
              'database' =&gt; 0,
       ],
  
  
      'clusters' =&gt; [
           'default' =&gt; [
              'host' =&gt; env('REDIS_HOST_1', '127.0.01'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; 6379,
              'database' =&gt; 0,
          ],
          'jobs' =&gt; [
              'host' =&gt; env('REDIS_HOST_2', '127.0.0.1'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port'     =&gt; 6379,
              'database' =&gt; 0,
          ],
          'content' =&gt; [
              'host' =&gt; env('REDIS_HOST_3', '127.0.0.1'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port'     =&gt; 6379,
              'database' =&gt; 0,
          ]
     ],
  
      'options' =&gt; [
          'cluster' =&gt; 'redis'
      ],
  ]
  </code></pre>
  
  <p>but I keep on getting this error</p>
  
  <pre><code>[2019-06-07 15:53:37] local.ERROR: Predis\Response\ServerException: MOVED 5873 127.0.0.1:7001 in /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Client.php:370 Stack trace: 
  0 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Client.php(335): Predis\Client-&gt;onErrorResponse(Object(Predis\Command\StringGet), Object(Predis\Response\Error)) 
  1 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Client.php(314): Predis\Client-&gt;executeCommand(Object(Predis\Command\StringGet)) 
  2 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(72): Predis\Client-&gt;__call('get', Array) 
  3 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(84): Illuminate\Redis\Connections\Connection-&gt;command('get', Array) 
  4 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(54): Illuminate\Redis\Connections\Connection-&gt;__call('get', Array) 
  5 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(84): Illuminate\Cache\RedisStore-&gt;get('cbwvtr3cxYIFP4H...') 
  6 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(68): Illuminate\Cache\Repository-&gt;get('cbwvtr3cxYIFP4H...') 
  7 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(305): Illuminate\Cache\Repository-&gt;has('cbwvtr3cxYIFP4H...') 
  8 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/Providers/Storage/IlluminateCacheAdapter.php(57): Illuminate\Cache\CacheManager-&gt;__call('has', Array) 
  9 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/Blacklist.php(74): Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter-&gt;has('cbwvtr3cxYIFP4H...') 
  10 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/JWTManager.php(83): Tymon\JWTAuth\Blacklist-&gt;has(Object(Tymon\JWTAuth\Payload)) 
  11 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/JWTAuth.php(190): Tymon\JWTAuth\JWTManager-&gt;decode(Object(Tymon\JWTAuth\Token)) 
  12 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/JWTAuth.php(124): Tymon\JWTAuth\JWTAuth-&gt;getPayload('eyJ0eXAiOiJKV1Q...') 
  13 /Users/Shared/dev/php/toters-api/app/Http/Middleware/TokenAuthentication.php(25): Tymon\JWTAuth\JWTAuth-&gt;authenticate('eyJ0eXAiOiJKV1Q...') 
  14 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\TokenAuthentication-&gt;handle(Object(Illuminate\Http\Request), Object(Closure)) 
  15 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) 
  16 /Users/Shared/dev/php/toters-api/app/Http/Middleware/WeakEtagMiddleware.php(22): Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) 
  17 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\WeakEtagMiddleware-&gt;handle(Object(Illuminate\Http\Request), Object(Closure)) 
  </code></pre>
  
  <p>Note I didn't make any application data changes, so my Redis code still looks like this:</p>
  
  <pre><code>use Illuminate\Support\Facades\Redis;
  ..
  
  Redis::set('key', 'val');
  </code></pre>
  
  <p>Further, If I remove the default from the above config so that it looks like so:</p>
  
  <pre><code>'redis' =&gt; [
       'client' =&gt; 'predis',
       'cluster' =&gt; 'true',
  
      'clusters' =&gt; [
           'default' =&gt; [
              'host' =&gt; env('REDIS_HOST_1', '127.0.01'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; 6379,
              'database' =&gt; 0,
          ],
          'jobs' =&gt; [
              'host' =&gt; env('REDIS_HOST_2', '127.0.0.1'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port'     =&gt; 6379,
              'database' =&gt; 0,
          ],
          'content' =&gt; [
              'host' =&gt; env('REDIS_HOST_3', '127.0.0.1'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port'     =&gt; 6379,
              'database' =&gt; 0,
          ]
     ],
  
      'options' =&gt; [
          'cluster' =&gt; 'redis'
      ],
  ]
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code>[2019-06-07 16:00:02] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Predis\Connection\Parameters::__construct() must be of the type array, integer given, called in /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Factory.php on line 164 in /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Parameters.php:34 Stack trace: 
  0 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Factory.php(164): Predis\Connection\Parameters-&gt;__construct(6379) 
  1 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Factory.php(84): Predis\Connection\Factory-&gt;createParameters(6379) 
  2 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Connection/Factory.php(118): Predis\Connection\Factory-&gt;create(6379) 
  3 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Client.php(135): Predis\Connection\Factory-&gt;aggregate(Object(Predis\Connection\Aggregate\RedisCluster), Array) 
  4 /Users/Shared/dev/php/toters-api/vendor/predis/predis/src/Client.php(56): Predis\Client-&gt;createConnection(Array) 
  5 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PredisConnector.php(41): Predis\Client-&gt;__construct(Array, Array) 
  6 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(102): Illuminate\Redis\Connectors\PredisConnector-&gt;connectToCluster(Array, Array, Array) 
  7 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(83): Illuminate\Redis\RedisManager-&gt;resolveCluster('default') 
  8 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(61): Illuminate\Redis\RedisManager-&gt;resolve('default') 
  9 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(211): Illuminate\Redis\RedisManager-&gt;connection('default') 
  10 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php(54): Illuminate\Cache\RedisStore-&gt;connection() 
  11 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(84): Illuminate\Cache\RedisStore-&gt;get('cbwvtr3cxYIFP4H...') 
  12 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(68): Illuminate\Cache\Repository-&gt;get('cbwvtr3cxYIFP4H...') 
  13 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(305): Illuminate\Cache\Repository-&gt;has('cbwvtr3cxYIFP4H...') 
  14 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/Providers/Storage/IlluminateCacheAdapter.php(57): Illuminate\Cache\CacheManager-&gt;__call('has', Array) 
  15 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/Blacklist.php(74): Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter-&gt;has('cbwvtr3cxYIFP4H...') 
  16 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/JWTManager.php(83): Tymon\JWTAuth\Blacklist-&gt;has(Object(Tymon\JWTAuth\Payload)) 
  17 /Users/Shared/dev/php/toters-api/vendor/tymon/jwt-auth/src/JWTAuth.php(190): Tymon\JWTAuth\JWTManager-&gt;decode(Object(Tymon\JWTAuth\Token)) 
  </code></pre>
  
  <p>So from the error message it seems that Predis is simply ignoring my clustered configuration and reading straight from default, and default doesn't know how to deal with my clustered Redis data store. Ideas?</p>