Unable to connect to Upstash Redis from Fly.io app using ioredis

Hi Fly.io community,

I’m encountering an issue connecting my NestJS backend application (hosted on Fly.io) to an Upstash Redis database using the ioredis library. I’ve set up the following secrets in my Fly.io app:

  • REDIS_HOST: My Upstash Redis endpoint (e.g., fly-old-river-93.upstash.io)
  • REDIS_PORT: The port provided by Upstash

However, I’m consistently getting the following error:

2025-06-05T04:24:32.808 app[48ed5d2b49e748] nrt [info] at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
2025-06-05T04:24:32.830 app[48ed5d2b49e748] nrt [info] [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND fly-old-river-93.upstash.io

Key details:

  1. I’m using the ioredis library in my NestJS application
  2. The error suggests DNS resolution is failing (ENOTFOUND)
  3. Upstash support suggested this might be a Fly.io-specific issue
  4. I’ve verified my Upstash credentials and endpoint are correct

Here’s my connection code snippet:

import Redis from 'ioredis';

const redis = new Redis({
  host: process.env.REDIS_HOST,
  port: parseInt(process.env.REDIS_PORT),
  // Other potential options I've tried:
  // tls: {}, // Tried with and without TLS options
  // retryStrategy: ... // Tried with retry strategies
});

Things I’ve already tried:

  • Verifying the Upstash endpoint is correct
  • Checking that secrets are properly set in Fly.io
  • Trying with and without TLS options
  • Testing the connection from my local machine (works fine)
  • “fly redis connect” command works perfectly on my local

Could this be related to:

  1. DNS resolution within Fly.io’s network?
  2. Missing network configuration in my Fly.io app?
  3. Any specific requirements for connecting to external services from Fly.io?

Any guidance or suggestions would be greatly appreciated!

1 Like

Hi… That sounds like it might be this classic IPv6 gotcha:

Hope this helps!

Also wanted to note that it’s possible to specify this in the URL’s query string by appending /?family=6, which avoids coupling the IPv6 requirement to the application itself.

3 Likes

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