2 years ago
Hi. I recently deployed my node.js app on Railway and found out that during startup of my node.js app, railway was unable to connect/find the local db instance. It eventually was able to connect to it, after a few retries. Is the problem on my side?
Error: P1001: Can't reach database server at `postgres.railway.internal`:`5432`
Please make sure your database server is running at `postgres.railway.internal`:`5432`.Not once does the local db instance restart during deployment of the app.
10 Replies
2 years ago
Could you try adding a 3 second sleep in your start command?
Now I only get the connection error once and on the second startup it successfully connects and I bet I get no error if I sleep like 6 seconds or so because first time I had two of these.
2 years ago
interesting, are you deploying an alpine based image?
FROM node:21-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN pnpm add turbo --global
COPY . .
RUN turbo prune backend --docker
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/full/packages/backend/prisma ./packages/backend/prisma
RUN pnpm install
COPY --from=builder /app/out/full/ .
RUN pnpm turbo build --filter backend
FROM base AS runner
WORKDIR /app
COPY --from=installer /app .
CMD pnpm start:backend2 years ago
in that case add a ENABLE_ALPINE_PRIVATE_NETWORKING service variable set to true
2 years ago
if you're curious about why this is necassery:
2 years ago
Awesome, no problem