I’m deploying a Node.js + Prisma backend using Docker on my VPS.
PostgreSQL is NOT in Docker — it runs directly on the VPS host (Ubuntu).
My backend is running inside Docker using docker compose.
DB_USER=vloq
DB_PASSWORD=******
DB_HOST=host.docker.internal
DB_PORT=5432
DB_NAME=furnix-staging
DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
Since the DB runs on the host machine, I correctly use
✅ What works
From inside the running Docker container, I can install PostgreSQL client and successfully connect:
docker exec -it furnix-backend sh
apk add postgresql-client
psql -h host.docker.internal -U vloq -d furnix-staging
❌ What fails
Prisma inside the backend container throws:
PrismaClientInitializationError:
Can't reach database server at `123:5432`
Important:
123 is NOT in my .env.
It looks like Prisma is reading an old or wrong DATABASE_URL.
Docker logs show:
Can't reach database server at `123:5432`
Even though .env says:
host.docker.internal
❓ What I suspect
Docker image may be caching the old
.envDATABASE_URLmay not be passed correctly bydocker-composePrisma may not see environment variables correctly during runtime
docker compose up -d --builddoes not reload.env
docker-compose.yml
services:
furnix-backend:
build: .
container_name: furnix-backend
restart: always
ports:
- "7778:7777"
env_file:
- .env
environment:
NODE_ENV: production
command: ["node", "dist/server.js"]
✔️ What I already tried
Rebuilt without cache:
docker compose down
docker compose build --no-cache
docker compose up -d
Verified .env on host — it is correct.
Verified DB connectivity from inside container.
Verified Prisma works locally.
❓ My Question
Why is Prisma inside the Docker container still trying to connect to:
123:5432
even though:
DB_HOST=host.docker.internal
is set correctly in .env, and psql from inside the container can connect successfully?
How can I ensure Docker / Prisma loads the correct .env so DATABASE_URL resolves properly?
docker container ls -a(2) find old container id likexxxx. (3) delete old container and volume:docker container rm -f -v xxxx.envor similar file built into your image? Can you logprocess.env.DATABASE_URLat startup to see if the right thing is coming out?