Happy Monday! I’ve recently run into a weird issue and can’t seem to figure out what would be causing it.
I have a NextJS project using Prisma and Supabase. When I run the app on my Windows desktop or Vercel, it runs perfectly with no error. However, when I run it on my MacBook, it presents me with this error:
Error:
Invalid `prisma.user.findUnique()` invocation:
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`.
Source
src/app/layout.tsx (37:17) @ async getData
35 | noStore();
36 | if (userId) {
> 37 | const data = await prisma.user.findUnique({
| ^
38 | where: {
39 | id: userId,
40 | },
I’ve looked around for some answers but can’t seem to find anyone with the same problem, any help would be appreciated!
2
Answers
Get Transaction and Session connection pooler string from your Superbase database setting page.
Transaction connection pooler string:
Session connection pooler string:
Update .env file:
schema.prisma file should look like:
From Superbase document
A solution that worked for me in the connection string for
directUrl = env("DIRECT_DATABASE_URL")
.