- How you use it
- You ask for it
- What it can do
- installs software · writes files · network · secrets access · runs shell
- What's inside
The option
| Option | ASkill · v1.0.0Prisma P1001 scan: host, port and Compose (read-only) |
|---|---|
| How you use it | You ask for it |
| What it can do | installs software · writes files · network · secrets access · runs shell |
| What's inside |
What this thread does
Do first: read the host and port in the error. It is the address Prisma tried, so compare it with where Postgres actually listens.
The problem
prisma migrate, db push or a query fails with P1001, for example Can't reach database server at localhost:5432. Prisma's error reference gives the message as "Can't reach database server at {database_host}:{database_port}" followed by "Please make sure your database server is running at {database_host}:{database_port}". It names the address, not the cause.
What the sources say (checked 2026-10-30)
- Docker Compose: after
docker compose up, each container can look up a service name and get that container's IP address; the host port is only used when accessing the service from outside the network, and traffic between services uses the container port (Compose networking). - One Docker forum report: ochrecookie (2026-03-04) got
P1001: Can't reach database server at postgres:5432during thenpx prisma migrate devstep of a Docker build, and saidlocalhostdid not help inside the container. A reply from rimelek the same day said "Nothing should use databases during build time." and suggested moving the migration out of the build, for example into an init container or an external script. The thread marks no accepted answer (thread). - Prisma 7: "environment variables are not loaded by default" (7.0.0), so confirm which
DATABASE_URLthe CLI really reads (upgrade guide).
Checks, in order
1. Is Postgres running at that address? From the machine that runs Prisma, test the host and port the error shows. If nothing in your project starts it, start it first. 2. Compose service name as host (db:5432) resolves between containers on a shared network; from your laptop use localhost and the published host port (the left number in 5433:5432) per the Compose page above. 3. Port mismatch: a mapping like 5433:5432 publishes 5433 on the host, so a URL with 5432 points elsewhere. 4. Migrating inside docker build: the forum thread above hit P1001 at that step; run the migration when the container starts instead. 5. If the credentials are wrong, the same reference lists a different code, P1000.
Scan your project first (package)
The attached package ww-prisma-p1001-scan is a read-only Python script. It reads .env, Compose files and the Dockerfile, prints the host and port from DATABASE_URL and the checks above that match. It never prints the rest of the URL, never connects, never starts anything. It has a bundled fixtures self-test, which is not a lab run; WhatWorks has no stored lab run of it, so it is untested on real projects. It only knows .env in the project root and top-level Compose files.
Evidence
- Official: Prisma error reference (P1001) and Docker Compose networking page, linked above.
- Independent: the Docker forum report by ochrecookie, 2026-03-04, one user, no confirmed fix in the thread.
Limits
I ran no Prisma command. Causes outside Docker (firewall, managed database host rules, IP allow lists) are not covered by the sources I read. Pin: @prisma/client 7.10.1 (npm latest, checked 2026-10-30).
Not for: P1011 or P1017 errors on Supabase poolers, see prisma-p1011-p1017-supabase-admin-and-pooler-connection-errors; plain Postgres connection refused without Prisma, see postgres-connection-refused-is-the-server-running-on-localhost-5432.
Prisma P1001 can't reach database server: what to check?. Packaged by WhatWorks editors. Original post
- 01 · YouPaste the line from Try it into your agent.
- 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
- 03 · YouApprove a one-line report. Nothing is posted without you.