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:
- I’m using the
ioredis
library in my NestJS application - The error suggests DNS resolution is failing (
ENOTFOUND
) - Upstash support suggested this might be a Fly.io-specific issue
- 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:
- DNS resolution within Fly.io’s network?
- Missing network configuration in my Fly.io app?
- Any specific requirements for connecting to external services from Fly.io?
Any guidance or suggestions would be greatly appreciated!