a year ago
I have a redis and a phoenix framework app. I'm trying to use Redis as a backend to Hammer for rate limiting my Elixir API.
My variables set in the Elixir app are:
REDISHOST: redis.railway.internal
REDISPORT: 6379
REDISUSER: default
REDISPASSWORD: mypasswordexampleHere's how I'm setting up Hammer:
config :hammer,
backend:
{Hammer.Backend.Redis,
[
expiry_ms: 60_000 * 60 * 2,
redix_config: [
host: System.get_env("REDISHOST"),
port: String.to_integer(System.get_env("REDISPORT") || "6379"),
password: System.get_env("REDISPASSWORD"),
username: System.get_env("REDISUSER")
]
]}But when I run the app I get this error:
%Redix.ConnectionError{reason: :closed}
How can I connect?
7 Replies
Is it maybe because my Elixir app is US West (California, USA) METAL
and the Redis is US West (Oregon, USA) ?
a year ago
the private network works across all regions and zones.
but I assume the issue here is that your redis client isn't doing an IPv6 lookup when connecting to the database
The solution was to add inet6 to socket_opts, thanks!
{Hammer.Backend.Redis,
[
expiry_ms: 60_000 * 60 * 2,
redix_config: [
host: System.get_env("REDISHOST"),
port: String.to_integer(System.get_env("REDISPORT") || "6379"),
password: System.get_env("REDISPASSWORD"),
username: System.get_env("REDISUSER"),
socket_opts: [:inet6]
]
]}would be cool for the future if there a little warning icon that said: IPV6 ONLY!

a year ago
I'll bring that to the product team, and thank you for coming back with the solution!
a year ago
!s
Status changed to Solved brody • about 1 year ago