Upstash Redis - Node - `Error: getaddrinfo ENOTFOUND`

Hi! Trying to implement Upstash Redis with Fly, but seeing this error on startup in the logs:

Redis error: Error: getaddrinfo ENOTFOUND
    "errno": -3007,
    "code": "ENOTFOUND",
    "syscall": "getaddrinfo",
    "hostname": ""

Steps taken:

  • I created my Redis database following the Fly docs
  • Copied the example code block from the Upstash console, replacing the *** with the my password from the console.
  • Checked everything is working fine locally running a server via redis-cli locally
  • Deployed via Fly and a Dockerfile. My Fly app and Upstash Redis instance are located in the same region (CDG)
  • Also tried adding { family: 6 } as a param to the Redis constructor (as others have had success with), which did not fix the issue.

Code - Node/Express

import { Redis } from "ioredis";

const connectionString =
  process.env.ENVIRONMENT === "development"
    ? "redis://"
    : process.env.REDIS_CONNECTION_STRING || "";

const redis = new Redis(connectionString);

Any ideas here my friends? :thinking:

Other useful info / screenshots?

Fly dash

Upstash console


# Use an official Node runtime as the base image

FROM node:20 as builder

# Set working directory


# Install dependencies

COPY package.json package-lock.json ./

RUN npm install

# Copy project files into the Docker image

COPY . .

# Build the project

RUN npm run build

# Use a multi-stage build to keep the image size small

FROM node:20-slim

# Set working directory


RUN mkdir -p ./speechFiles

# Copy built artifacts from the builder stage

COPY --from=builder /app/dist ./dist

# Copy package.json and other necessary files for running the application

COPY package.json package-lock.json ./

# Install production dependencies

RUN npm install --production

# Copy Google Cloud credentials into the container

COPY application_default_credentials.json /app/google-credentials.json


ENV GOOGLE_APPLICATION_CREDENTIALS=/app/google-credentials.json

# Run the app

CMD ["npm", "start"]

{family: 6} should do it. Can you post your full config using that param, and try agian to see if it could have been a delay in DNS propagation?

Also try running dig +short AAAA from your vm console if you have it installed. You should see a resolved IPv6 address.

Edit: seemed to have solved this halfway through writing this message… adding a solution to the bottom but keeping the rest as a reference for anyone looking for the same issue. Btw Josh, thanks for the response above and appreciate all the work you and the team are doing - love Fly’s DX and learning a lot along the way!

I’m bumping up against my skill level with containers/VM here, but running: flyctl --machine machineId followed by dig +short AAAA gave me -bash: dig: command not found.

However just running dig -t AAAA directly in my terminal gave me fdaa:0:e422:0:1::2. I also deployed a log programmatically using dns.resolve6("", ...) which also gave me fdaa:0:e422:0:1::2 in my application logs within the container.

A bit of progress though - before I was passing the { family: 6 } as a second param to the Redis constructor and getting the error in the original post. If I pass it as a query param to my connection string like "redis://default:***" I’m getting a new error message:

Error: read ECONNRESET
    errno: -104,
    code: 'ECONNRESET',
    syscall: 'read'

So it now seems like it’s connecting to the Redis server at Upstash, but it’s getting reset every few seconds…

Splitting the connection string into an object has done the trick - I’m now successfully reading/writing the cache in production.

const redis = new Redis({
  host: "",
  port: 6379,
  username: "default",
  password: "******",
  family: 6,

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