prisma: Unable to reach database server at aws-0-us-east-1.pooler.supabase.com:5432 using Prisma migrate dev
Bug description
I am encountering an issue where I am unable to connect to my Supabase PostgreSQL database server using Prismaβs migrate dev command. This problem started occurring suddenly and was not an issue previously. I have made sure my supabase pooler connection is transaction at port: 6543 but it consistenly says to connect to port: 5432. I have also tried including direct connection but the same error appears. My supabase is active.
(venv): npx prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "aws-0-us-east-1.pooler.supabase.com:5432"
Error: P1001: Can't reach database server at `aws-0-us-east-1.pooler.supabase.com:5432`
Please make sure your database server is running at `aws-0-us-east-1.pooler.supabase.com:5432`.
How to reproduce
Steps to Reproduce:
Set up a PostgreSQL database on Supabase. Configure Prisma with the Supabase database connection. Run the command npx prisma migrate dev.
Expected behavior
Prisma should successfully connect to the database and apply migrations.
Prisma information
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id
email String @unique
name String?
password String?
flashcards Flashcard[]
}
model Flashcard {
id String @id @default(uuid())
question String
answer String
order Int
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
export default prisma
Environment & setup
- OS: Windows
- Database: Supabase
- Node.js version: v20.12.1
Prisma Version
v5.17.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 19 (1 by maintainers)
Still happening in 2025 π
How I Solved Prisma Migration Error with Supabase (P1001)
After a lot of trial and error β deleting and recreating the Supabase project, changing the database password, and attempting migrations multiple times β I finally found a solution.
In my case, I was using Prisma with Supabase.
psqlworked fine.Solution
I added timeout parameters to both
DATABASE_URLandDIRECT_URLin my.envfile.β Old Version (was failing)
β New Version (worked for me)
Hope this helps someone else struggling with the same issue! π
Actually it now works for me. I was using the incorrect password. The password for my actual project was needed to use for me. I was using something else.
I share the same problem at OP:
What worked
https://github.com/supabase/supabase/issues/29856#issuecomment-2484186297
More context:
session poolconnection type. username: postgres password: [from project settings --> database]