Cannot connect to redis

I’ve looked through several of the threads and I just can’t connect to redis.

Here is my config:

Redis fly.toml

app = "app-name-redis"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

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

[env]

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]

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

App fly.toml

app = "app-name"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  builder = "heroku/buildpacks:20"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = 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]]
    force_https = true
    handlers = ["http"]
    port = 80

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

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

And my ioredis code in index.ts

const redisClient = new Redis({
        port: 6379,
        family: 6,
        host: "app-name-redis.internal",
        password: "<PASSWORD>",
})

I get this error:

[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1229:16)

I have made sure to set the REDIS_PASSWORD variable on the redis side.

Any ideas?

Im having the same problem. I think the host is supposed to be appname.internal not appname-redis.internal. the redis application and the whatever application connecting to the redis app have to be in the same org

For version 3 of that drive, you need to specify family: "IPv6". Version 4 needs socket: { family: 6 }. It’s horribly confusing, see here: Specify ip version? · Issue #1741 · redis/node-redis · GitHub