Accessing redis cluster from Phoenix/Elixir App

Hello,

I have a Phoenix app already running and now I’m trying to add a caching layer using redis. I have the redis server running the same org as phoenix app but I am not able to connect to it from Elixir IEX console. I am able to ssh into the redis server and use the redis-cli with no problems.

Here is what I’m trying

{:ok, conn} = Redix.start_link(host: "redis-cache-name.internal", port: 6379)

Redix.command(conn, ["AUTH", "my_secret_pass"])

I keep getting {:error, %Redix.ConnectionError{reason: :closed}}

Has anyone able to successfully use Redis and Phoenix app on fly.io ?

A hit or miss suggestion if you want to try:

Try adding socket_opts like this:

Redix.start_link(
  host: "redis://vodon-redis.internal/1",
  socket_opts: [:inet6]
)

Ref: https://github.com/whatyouhide/redix/issues/222

Thank you for posting this!

After bashing my head against the wall trying to get exq which uses redix connecting I stumbled upon you anwser. Dropping in socket_opts: [:inet6] worked a treat.

Just spent way too long figuring this out. Thanks!