If you’re attempting to use DigitalOcean’s Managed Redis Database with Laravel then you may run into some issues. The Redis server requires an encrypted connection. However, Laravel defaults to an unencrypted connection. The page will probably show a vague 500 server error.

In order to fix this, you need to update the config/database.php file like shown below. You need to add 'scheme' => 'tls',. Also, DigitalOcean gives you a username to use, but you don’t need it.

Config

<?php
// config/database.php
// ...
'default' => [
    'scheme' => 'tls',
    'url' => env('REDIS_URL'),
    'host' => env('REDIS_HOST', '127.0.0.1'),
    'password' => env('REDIS_PASSWORD', null),
    'port' => env('REDIS_PORT', '6379'),
    'database' => env('REDIS_DB', '0'),
],

'cache' => [
    'scheme' => 'tls',
    'url' => env('REDIS_URL'),
    'host' => env('REDIS_HOST', '127.0.0.1'),
    'password' => env('REDIS_PASSWORD', null),
    'port' => env('REDIS_PORT', '6379'),
    'database' => env('REDIS_CACHE_DB', '1'),
],

Errors

Here is the first error I got.

Error while reading line from the server.

I got this one from adding tls:// to the hostname of the Redis connection.

php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution