Internal Redis Connection Error: connect ECONNREFUSED

I’ve read through all the forums related to this problem but I can’t find a solution. I have a web application, a worker and a redis instance set up in fly. The webapp is not connecting the the redis instance correctly. Here’s the web app toml. I’m using BullMQ to create the queue and the job is created fine. That seems to work. The error Error: connect ECONNREFUSED is continually logged and the queue cannot listen to onComplete changes.

app = "vel-new"
kill_signal = "SIGINT"
kill_timeout = 5
processes = [ ]

PORT = "8080"

allowed_public_ports = [ ]
auto_rollback = true
private_network = true 

internal_port = 8_080
processes = [ "app" ]
protocol = "tcp"
script_checks = [ ]

  hard_limit = 25
  soft_limit = 20
  type = "connections"

  handlers = [ "http" ]
  port = 80
  force_https = true

  handlers = [ "tls", "http" ]
  port = 443

  grace_period = "1s"
  interval = "15s"
  restart_limit = 0
  timeout = "2s"

If you have two separate apps/instances and you are getting this error message: Error: connect ECONNREFUSED – I think the problem is because the app is trying to connect to itself/localhost and not vel-new.internal as you might wish.


I’m setting the address via a secret suggested by the documentation

fly secrets set REDIS_URL=redis://default:password@redis-xyz.internal:6379 -a vel-new

Try connecting over and listening on ipv6.

How is your app reading the REDIS_URL from the env? It defines redis-xyz.internal but the error references; are any of the settings coming through?

I know that BullMQ uses the REDIS_URL environment variable and I think you said that part worked, so I’m wondering if your web app is also using REDIS_URL or not, because the error implies it is not. If it’s a Node.js app, not all the Redis client libraries will default to using the environment variable and you need to pass in process.env.REDIS_URL so it could be that.