I started learning about prisma and supabase and would like to implement both technologies in my Next.js app. After running npx prisma migrate dev --name init
I was faced with the following error:
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "db.xocheossqzkirwnhzxxm.supabase.co:5432"
Error: P1001: Can't reach database server at `db.xocheossqzkirwnhzxxm.supabase.co`:`5432`
Please make sure your database server is running at `db.xocheossqzkirwnhzxxm.supabase.co`:`5432`.
my password to the db does not contain any special characters here is my schema.prisma file:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Home{
id String @id @default(cuid())
image String?
title String
description String
price Float
guests Int
beds Int
baths Int
createdAt DateTime @default(now())
updateAt DateTime @updatedAt
}
here is my .env:
DATABASE_URL="postgresql://postgres:[YOUR-PASSWORD]@db.xocheossqzkirwnhzxxm.supabase.co:5432/postgres"
I had a similar issue with a Sveltekit application using Prisma and PlanetScale (MySQL) and Docker on Windows (WSL). I received the same error but did not have this issue when I ran it directly from terminal nor when I connected through the mysql cli.
I ensured that my Docker Node version was the same as on WSL (16.15), I have noticed others have had this issue with different versions of Node so it is worth exploring this. I then added connect_timeout=300
to my SQL URL to prevent the connection from timing out too early.
I include more details in my other answer on Stackoverflow.