1 month ago

Getting `read error on connection` when trying to use DigitalOcean managed Redis

Posted 1 month ago by AlexGodbehere

I'm looking to scale my application from a single server to multiple, so I've set up a brand new Redis managed database on DigitalOcean. After trying to point my Laravel app to use it I'm getting a read error on connection error. Having scouted around the internet for the best part of a day, I've realised that it doesn't seem to be a common issue. I'm running Laravel 6.2, phpredis 5.1.1 and php 7.3.13. I've allowed my droplet to access the Redis instance over private networking.


My config/database looks like this:

'redis' => [

            'client'  => 'phpredis',
            'cluster' => false,

            'default' => [
                'scheme'   => 'tls',
                'host'     => env('REDIS_HOST', ''),
                'password' => env('REDIS_PASSWORD', null),
                'port'     => env('REDIS_PORT', 6379),
                'database' => env('REDIS_DB', 0),

            'cache'   => [
                'scheme'   => 'tls',
                'host'     => env('REDIS_HOST', ''),
                'password' => env('REDIS_PASSWORD', null),
                'port'     => env('REDIS_PORT', 6379),
                'database' => env('REDIS_CACHE_DB', 1),
            'options' => [
                'prefix'     => env('REDIS_PREFIX', Str::slug(env('APP_ENV', 'ENVNOTDEFINED'), '_').'_database_'),
                'parameters' => ['password' => env('REDIS_PASSWORD', null)],

And my .env file contains the required values:

I found this question, but becasue I'm already running later versions than the suggested fix, the answer didn't solve my problem.

Has anyone encountered this before?

Please sign in or create an account to participate in this conversation.