Unable to use redis ..

> fly ssh console --pty -C "/app/bin/rails console"
Connecting to fdaa:0:8ec9:a7b:17c:3954:e67a:2... complete
Loading production environment (Rails 6.1.7.2)
/app/vendor/bundle/ruby/3.0.0/gems/redis-4.8.1/lib/redis/client.rb:398:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
/usr/lib/fullstaq-ruby/versions/3.0.6-jemalloc/lib/ruby/3.0.0/socket.rb:1214:in `__connect_nonblock': Connection refused - connect(2) for 127.0.0.1:6379 (Errno::ECONNREFUSED)
/usr/lib/fullstaq-ruby/versions/3.0.6-jemalloc/lib/ruby/3.0.0/socket.rb:1214:in `__connect_nonblock': Operation now in progress - connect(2) would block (IO::EINPROGRESSWaitWritable)
2023-07-22T16:28:55Z app[9080e445a63e08] nrt [info][f059dcf5-9d88-432b-a796-60ba486ebf9c] Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)):

fly.toml

# fly.toml file generated for ...... on 2022-11-22T11:13:16+08:00

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

[build]
  [build.args]
    BUILD_COMMAND = "bin/rails fly:build"
    SERVER_COMMAND = "bin/rails fly:server"

[deploy]
  release_command = "bin/rails fly:release"

[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"

[[statics]]
  guest_path = "/app/public"
  url_prefix = "/"

Unable to use redis …
How to fix it please? :face_with_spiral_eyes:

This indicates that Rails is trying to connect to Redis on your local host, which generally means that the REDIS_URL secret is not set.

If you have not already done so, run fly redis create to create a Redis database. You can use fly redis list to check.

fly redis status will show the private URL for that database. Replace the URL in the following with the URL the status command returns.

fly secrets set REDIS_URL=redis://...
2 Likes

Turns out I forgot to do something basic… Thank you very much for reminding :+1:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.