Can not connect to Redis over private network

Hey,

I seem to be having issues connecting to my Redis application (on same organisation account) from another application.

[ioredis] Unhandled error event: Error: getaddrinfo EAI_AGAIN redis.internal
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) node:events:368
throw er; // Unhandled 'error' event

My Redis applicaiton appears to be running as expected;

app[2c581401] lax [info] e[1;38;5;2mredis e[0m | 532:M 06 Jan 2022 14:13:52.898 # Server initialized
app[2c581401] lax [info] e[1;38;5;2mredis e[0m | 532:M 06 Jan 2022 14:13:52.899 * Ready to accept connections
app[2c581401] lax [info] e[1;38;5;3mmetricse[0m | e[36mINFOe[0m[0000] Redis Metrics Exporter v1.31.4 build date: 2021-11-17-12:31:49 sha1: f6e78de9161444a51c8c33fccf223d8d0ae11d4a Go: go1.17.3 GOOS: linux GOARCH: amd64
app[2c581401] lax [info] e[1;38;5;3mmetricse[0m | e[36mINFOe[0m[0000] Providing metrics at :9091/metrics

Redis application:

# fly.toml file generated for redis on 2022-01-06T14:02:56Z

app = "redis"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  image = "flyio/redis:6.2.6"

[[mounts]]
  destination = "/data"
  source = "redis_server"

[metrics]
  port = 9091
  path = "/metrics"

[experimental]
  auto_rollback = true

Backend application:

# fly.toml file generated for backend on 2022-01-07T09:44:17Z

app = "backend"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true
  private_network = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Any help would be greatly appreicated.

Thank you,
Alex

A couple of random thoughts. But you may have already tried these.

Are you connecting from your app using redis.internal:6379 ?

Have you got a password set on the Redis?
fly secrets set REDIS_PASSWORD=PASSWORD
I believe (may be wrong) the Fly Redis needs one. And then connect using that password from your app.

If neither of these is the issue, Iโ€™m sure someone else can help.

(post deleted by author)

Thank you, unfortunately those have already been done yes. I also tried merging the 2 but still no luck (i.e REDIS_URL=redis://:PASSWORD@redis.internal:6379).

Ok. In which case โ€ฆ maybe this issue could be it?

The test is apparently to use the IPv4 of the Redis app (in place of redis.internal in the connection URL) and see if that works:

Still no luck through the IPv4 address (REDIS_URL=redis://213.188.207.23:6379) unfortunately.

Ah.

The final thing would be to try using the suggested 6 in the config options, going back to redis.internal, and the password. Which you may have already tried too:

If that doesnโ€™t work hopefully someone from Fly can assist. Like whether internal_port = 8080 should be internal_port = 6379. Or some other config change to make the networking work.

2 Likes

The 'family': '6' config option is almost definitely what you need! my-redis.internal only returns IPv6 addresses, and ioredis looks for IPv4 records by default.

You can simulate your appโ€™s DNS lookup with the fly dig command:

fly dig aaaa redis-app-name.internal -a backend-app-name