Dwight Watson's blog

Laravel with Heroku Redis and SSL

Redis 6.x appears to require SSL for connections and that's a problem with Heroku. Heroku does have documentation on how to get around errors with self-signed cerificates but it falls short of addressing the solution specifically for Laravel apps.

Redis::connect(): SSL operation failed with code 1. OpenSSL Error messages:
error:0A000086:SSL routines::certificate verify failed

In config/database.php under the redis key you can control the options for your Redis connection. Here you can add a context which sets verify_peer and verify_peer_name to false so that the certificate issues are ignored. In the code below I've only applied these options in the production environment as it's not a concern for my local environment.

'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
'context' => env('APP_ENV') === 'production' ? [
'stream' => [
'verify_peer' => false,
'verify_peer_name' => false,
] : [],

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.