Can't connect to Redis using
redis.railway.internal
sergiotapia
PROOP

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: mypasswordexample

Here'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?

Solved

7 Replies

sergiotapia
PROOP

a year ago

ac62f702-07b5-4319-85e4-aab729599d4a


sergiotapia
PROOP

a year ago

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


sergiotapia
PROOP

a year ago

that makes sense, deploying and testing now


sergiotapia
PROOP

a year ago

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!

1328254725170266000


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


Loading...