PrismaP
Prisma8mo ago
7 replies
Bibi_la_truite

Problem: npx prisma migrate dev fails with Error P3006 (but database is reachable)

I'm running into an issue with Prisma Migrate and can't find a solution after trying multiple approaches.

---

Initial Setup


I started with an existing PostgreSQL DB (running on Windows Server, not Docker). Here's what I did:

1. Pulled the schema:
   npx prisma db pull


2. Created initial migration folder:
   mkdir -p prisma/migrations/0_init


3. Generated the SQL migration:
   npx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > prisma/migrations/0_init/migration.sql


4. Marked migration as applied:
   npx prisma migrate resolve --applied 0_init


5. Then ran:
   npx prisma migrate dev


---

The Problem


When running npx prisma migrate dev, I get:

Error: P3006

Migration `0_init` failed to apply cleanly to the shadow database. 
Error code: P1001
Error:
Can't reach database server at `192.168.1.228:5432`

Please make sure your database server is running at `192.168.1.228:5432`.


However, the DB is reachable npx prisma db pull works fine.

---

What I Tried


* Set a valid shadowDatabaseUrl → no change
* Tried migrate resolve --rolled-back and --applied
* Tested with a minimal DB → same error
* Confirmed PostgreSQL user is a superuser
* Not running in Docker → not a container issue

---

Info


* DB: PostgreSQL (Windows Server)
* Backend: NestJS
* Prisma/CLI version: 6.9.0

---

Question


Has anyone faced an issue where prisma migrate dev can't reach the shadow DB, even though db pull works?

Could this be specific to how Prisma handles shadow DBs on non-Docker Windows setups?

Any help appreciated!
Was this page helpful?