Reputation: 1
I’m supposed to be working on a team project using a Next.js monorepo with a PostgreSQL backend, both running in Docker containers.
Important: I get the same error both on mac and windows!!
The application runs successfully for my teammates, but I’m encountering an issue when starting the development server.
Steps I take to run the server: Run pnpm docker:db:rebuild, which executes:
pnpm docker:db:down
pnpm docker:db:init
Once migrations complete successfully, I run pnpm dev. At this point, I get the following error
"Type of stack undefined
api:dev: Feb 24 16:53:31 error: [api] Error executing user/getUser: Error: getaddrinfo ENOTFOUND db.localtest.me
api:dev: at C:\Users\ggmio\projects\squared\squared\node_modules\.pnpm\@[email protected]\node_modules\@neondatabase\serverless\index.js:1345:74
api:dev: at processTicksAndRejections (node:internal/process/task_queues:105:5)
api:dev: at async NeonPreparedQuery.execute (C:\Users\ggmio\projects\squared\squared\node_modules\.pnpm\[email protected]_@[email protected]_@[email protected]_@prisma+client@6._2ikk3wxp2xyn2wfim62gbnon7q\node_modules\src\neon-serverless\session.ts:102:18)
api:dev: at async UserService.getUser (C:\Users\ggmio\projects\squared\squared\apps\api\src\services\users\user-service.ts:97:10)
api:dev: at async postHandler (C:\Users\ggmio\projects\squared\squared\packages\rpc\src\index.ts:123:21)
web:dev: Error occurred during RPC request: RpcResponseError: getaddrinfo ENOTFOUND db.localtest.me
web:dev: at mapError (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\[root of the server]__6b4763._.js:1206:11)
web:dev: at UserService.doRequest (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\[root of the server]__6b4763._.js:1178:17)
web:dev: at async (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\[root of the server]__6b4763._.js:1911:18)
web:dev: at async Object.wrapperFunction [as handler] (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\[root of the server]__6b4763._.js:247:29)
web:dev: at async dispatch (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\08b5e__pnpm_be0601._.js:901:27)
web:dev: at async handler (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\08b5e__pnpm_be0601._.js:1074:45)
web:dev: at async dispatch (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\08b5e__pnpm_be0601._.js:901:27)
web:dev: at async Object.wrapperFunction [as handler] (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\[root of the server]__6b4763._.js:256:17)
web:dev: at async dispatch (C:\Users\ggmio\projects\squared\squared\apps\web\.next\server\edge\chunks\08b5e__pnpm_be0601._.js:901:27) {
web:dev: code: 'unknown_error',
web:dev: type: 'error',
web:dev: source: [ 'user/getUser' ],
web:dev: status: 400
web:dev: }"
Note: db.localtest.me is a proxy for the neon serverless postgres driver
Since this is a monorepo with multiple Docker services, a fully minimal example isn't feasible without sharing the entire project.
This is the docker-compose.yaml file we have in the root directory
web:
container_name: web
build:
context: .
dockerfile: ./apps/web/Dockerfile
image: <image>:latest #redacted
restart: always
ports:
- 3000:3000
networks:
- app_network
env_file:
- .env
api:
container_name: api
build:
context: .
dockerfile: ./apps/api/Dockerfile
restart: always
ports:
- 5173:5173
networks:
- app_network
env_file:
- .env
image: <image>:latest #redacted
networks:
app_network:
external: true
and this one in the seed package
services:
postgres:
image: postgres:17
command: "-d 1"
volumes:
- db_data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_USER=<user> #redacted
- POSTGRES_PASSWORD=<password> #redacted
- POSTGRES_DB=<db> #redacted
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
neon-proxy:
image: ghcr.io/timowilhelm/local-neon-http-proxy:main
environment:
- PG_CONNECTION_STRING=postgres://postgres:my-postgres@postgres:5432/db #redacted
ports:
- "4444:4444"
depends_on:
postgres:
condition: service_healthy
volumes:
db_data:
Additional context:
Environment variables and database configurations are correct.
Other team members can run the app without issues.
The database should be accessible via db.localtest.me, but it seems my setup is unable to resolve it.
I can connect to the database using Drizzle Studio, but the application still fails to connect.
Docker version used for windows : docker engine 27.5.1, docker desktop 4.38.0
postgreSQL version 17.3
✅ Network & Firewall Checks:
Disabled the firewall to rule out blocking issues.
Verified that both the database and app containers are on the same Docker network (they are).
✅ Host & DNS Resolution:
Checked the etc/hosts file on Windows – confirmed that localhost resolves to 127.0.0.1.
Confirmed that db.localtest.me should be resolving correctly.
✅ Database Accessibility:
Ran Docker commands in the terminal – successfully accessed the database via CLI.
Verified that the database is accessible using Drizzle Studio.
✅ Cache & Miscellaneous Fixes:
Cleared cache and cookies to eliminate potential stale configurations.
Upvotes: 0
Views: 16