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 prismaschema.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"
4
Answers
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.
Solution
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
connection_timeout=300
to my SQL URL to prevent the connection timing out too early.I include more details in my other answer on Stackoverflow.
I had the same issue with supabase, and I just switched to a private net. I was using my University Wifi. Try using your hotspot.
Maybe Docker is hosted in a public net?
Im not sure if thats helps you, but I spent some months trying to fix it, maybe can be useful for others.
I had a similar error and in my case i was running a VPN (Proton VPN) in background on my local computer.
I Manage to resolve the problem by stopping the vpn.
For people who haven’t solved this problem, try to delete and recreate the project on Supabase (I tried to set my password as a chain of digits, regardless not work the first time but after that, I reset my pw with exactly the same with the previous) surprisingly it worked after hours looking for solutions on the internet. Hope you too!