Can't connect to REDIS

Hi,

I’m trying to connect to a fresh Redis database created using the fly launch command. I get the correct URL but I cannot connect to the database. Trying with both the actual deployed container and from my computer. Both yield no results.

I’m using Node:

[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND fly-spshe-price-redis.upstash.io

  let client = new Redis(REDIS_URL);

  client.get(key, (err, result) => {
    if (err) {
      res.send(err, 500)
    } else {
      console.log(result); // Prints "value"
      res.send(result)
    }

Hi @julienlucca

If you are using ioredis library try the following:

const Redis = require("ioredis");

let client = new Redis("redis://:********@fly-spshe-price-redis.upstash.io:6379");
client.set('foo', 'bar');

Hope that helps,
Sergio Turpín

Hey @sturpin!

Thanks for replying! I’ve also followed the instructions when using fly.io link to “Visit the Upstash dashboard”, that contains this snippet you just shared.

It didn’t worked either. I also can’t connect to it using a client like redis-cli.

Hey, does flyctl redis connect work for you?

Connecting with ioredis and similar requires specifying the IPv6 family like:

new Redis({
  host: "fly-spshe-price-redis.upstash.io",
  family: 6,
  password: "yourpass"
})

Hey, does flyctl redis connect work for you?

It does!

Tried the snippet and it doesn’t work either… Really not sure why.

I’ve tried spinning up a new fresh redis database using Upstash directly and it works just fine. The thing that I noticed is that on Upstash I get SSL support (or at least the option to make it work) and it connect with no problems, local or deployed on fly.io

Are you connecting from within the same Fly organization as your Redis deployment? You wouldn’t be able to connect from your local machine because your database is only available from within the same Fly org.

yes. I’ve tried both scenarios, both yield the same results, sadly. I’ve also double checked if the machine and the database are in the same organization and it is. I’ve created both using fly launch on the same prompt btw.

For now I’m using a separate instance on Upstash. It would be good to use the managed one, since I could simply use the provided ENV var.

OK - can you leave the Redis instance running for debugging?

Sure, I can also share the password if needed, lmk

I wasn’t able to detect any issues connecting to this instance. If you could share a test case, runnable with nodejs, that would help.

Were you able to resolve this? I am running into the same issue. I can’t connect from my computer. Both from my application and redis CLI so this looks like a networking issue from the redis instance. fly redis connect works

I ended up deleting the whole stack and creating a new one

I am stuck with the same issue.

getting errors:

[ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND fly …

If I SSH into the machine and try to redis-cli -h '...' that works

seems like something is borked with hostname resolution within node.js process

I think this could be fixed if there was a way to enable ssl, but I cannot find this option when creating upstash instances using CLI?

I signed up directly with Upstash, enabled SSL, and that worked.