title: AWS ElastiCache Redis can't connect from Laravel nad from redis-cli
body: <p>I'm having a problem connecting to ElastiCache Redis from Laravel application installed on EC2 instance or even using redis-cli from EC2 instance. </p>
  
  <p><strong>Laravel</strong></p>
  
  <p>I tried to use predis with configurations in database.php like</p>
  
  <pre><code>    'redis' =&gt; [
      'client' =&gt; 'predis',
      'default' =&gt; [
          'host' =&gt; env('REDIS_HOST', '127.0.0.1'),
          'password' =&gt; env('REDIS_PASSWORD', null),
          'port' =&gt; env('REDIS_PORT', 6379),
          'database' =&gt; 0,
          'read_write_timeout' =&gt; -1,
          'timeout' =&gt; 0
      ],
  ],
  </code></pre>
  
  <p>and got '<code>Error while reading line from the server. [tcp:server here]</code>'</p>
  
  <p>I tried with phpRedis extension with same configurations only change <code>'client' =&gt; 'phpredis'</code> and got error <code>read error on connection {"exception":"[object] (RedisException(code: 0): read error on connection at vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:69)
  </code></p>
  
  <p><strong>Redis cli</strong></p>
  
  <p>Using redis cli <code>redis-cli -h host_here -p 6379 -a password_here</code> I see prompt like <code>host:6379&gt;</code> but typing any command throws error <code>Error: Connection reset by peer</code></p>
  
  <p><strong>ElastiCache Redis configurations</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ISjhJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ISjhJ.png" alt="enter image description here"></a></p>
  
  <p>My EC2 and elastic cache are in the same VPC and using telnet I can connect to redis instance</p>
  
  <pre><code>~$ telnet host 6379
  Trying 172.31.23.113...
  Connected to host.
  Escape character is '^]'.
  </code></pre>
  
  <p>Thanks for any help!</p>