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)

Most upvoted comments

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.

  • Testing the database connection manually using psql worked fine.
  • Running a Prisma migration kept failing with a connection error (P1001).

Solution

I added timeout parameters to both DATABASE_URL and DIRECT_URL in my .env file.


❌ Old Version (was failing)

# Pooled connection for Prisma Client
DATABASE_URL="postgresql://postgres:[YOUR_PASSWORD]@aws-0-us-east-2.pooler.supabase.com:5432/postgres?pgbouncer=true"

# Direct connection for Prisma Migrate
DIRECT_URL="postgresql://postgres:[YOUR_PASSWORD]@db.[PROJECT_REF].supabase.co:5432/postgres"

βœ… New Version (worked for me)

# Pooled connection for Prisma Client
DATABASE_URL="postgresql://postgres:[YOUR_PASSWORD]@aws-0-us-east-2.pooler.supabase.com:5432/postgres?pgbouncer=true&connect_timeout=30&pool_timeout=30"

# Direct connection for Prisma Migrate
DIRECT_URL="postgresql://postgres:[YOUR_PASSWORD]@db.[PROJECT_REF].supabase.co:5432/postgres?connect_timeout=30"

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:

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`.

What worked

brew install postgresql^16
brew link --overwrite postgresql@16

https://github.com/supabase/supabase/issues/29856#issuecomment-2484186297

More context:

  • connecting ipv4 from Asia
  • using ohmyzsh and zsh
  • m1 macbook pro
  • using session pool connection type. username: postgres password: [from project settings --> database]