AWS ElasticCache Cluster with TLS — Encryption in Transit — Laravel

Joshua Callis
Mar 23, 2022

Recently went through the pain of getting a bunch of errors, most notably

“ Error while reading line from the server.”

when trying to connect to a new ElasticCache cluster in AWS that is multi-az and has encryption/encryption at rest enabled.

By default Laravel doesn’t set the cluster configs and the default scheme is tcp, which obviously can’t be used on a cluster that requires TLS :(

To keep it to the point…

Set the cluster configuration and change the scheme to tls and also remove the default 60 second time out, by setting read_write_timeout to -1.

Redis configuration in config/database.php will look like the following..

--

--

Joshua Callis

Converted DevOps Engineer at oso.sh, Previously a Senior Software Engineer.