Hi! Trying to implement Upstash Redis with Fly, but seeing this error on startup in the logs:
Redis error: Error: getaddrinfo ENOTFOUND fly-withered-wildflower-4438.upstash.io
{
"errno": -3007,
"code": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "fly-withered-wildflower-4438.upstash.io"
}
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://127.0.0.1:6379"
: process.env.REDIS_CONNECTION_STRING || "";
const redis = new Redis(connectionString);
Any ideas here my friends?
Other useful info / screenshots?
Fly dash
Upstash console
Dockerfile
# Use an official Node runtime as the base image
FROM node:20 as builder
# Set working directory
WORKDIR /app
# 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
WORKDIR /app
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
# Set GOOGLE_APPLICATION_CREDENTIALS environment variable
ENV GOOGLE_APPLICATION_CREDENTIALS=/app/google-credentials.json
# Run the app
CMD ["npm", "start"]