How does one connect to an Upstash Redis database programmatically?

The Upstash dashboard provides an example to connect to my Redis instance using a connection string:

const Redis = require("ioredis");

// Using *** to mask my credentials
let client = new Redis("redis://:***@fly-***");
client.set('foo', 'bar');

However, this does not work (unable to connect).

Apparently, you need to use the IPV6 address to connect to the instance.

So I tried multiple combinations of x.internal and specifying the family to 6, but still no success.

What’s the actual connection string I should use to connect to my Redis instance? :no_mouth: Is there anything particular I need to do beforehand? :no_mouth:

Thanks for the guidance :pray:

We just set this up with ioredis. Make sure to:

  • Connect with IPv6 (you already mentioned this)
  • Connect from within the Fly network. This is automatic from any Fly app, but in development you’ll need to activate a Wireguard tunnel on your machine or use the fly proxy command.
const Redis = require("ioredis");
const client = new Redis(
  { family: 6 }
1 Like

Thanks for the reply Elliot :pray:

Connect with IPv6 (you already mentioned this)

How does one do that? Is simply passing in the family: 6 option enough? Do I need to use some sort of .internal address, or can I simply use the url?


Using the family: 6 option with the Upstash URL works great. Thanks :blush:

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