Prisma unable to connect to Supabase database
See original GitHub issueBug report
Describe the bug
Prisma npx commands and Prisma Studio are unable to connect to the Supabase database.
Running npx prisma migrate dev
yields in the following error message:
> npx prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "db.xltfmrlaegzuuopvypxx.supabase.co:5432"
Error: P1001: Can't reach database server at `db.xltfmrlaegzuuopvypxx.supabase.co`:`5432`
Please make sure your database server is running at `db.xltfmrlaegzuuopvypxx.supabase.co`:`5432`.
I followed the advice at https://github.com/prisma/prisma/issues/13807 and I was indeed able to migrate an initial db after creating a temporary table.
But after running Prisma Studio I am unable to add any entries and once more unable to migrate a database:
Type: undefined
Message:
Invalid `prisma.home.create()` invocation:
Can't reach database server at `db.xltfmrlaegzuuopvypxx.supabase.co`:`5432`
Please make sure your database server is running at `db.xltfmrlaegzuuopvypxx.supabase.co`:`5432`.
Code: undefined
Query:
[object Object]
I made sure that my database password contains no special characters as #4161 discussed.
Using psql to connect to the data base shows no issues either and shows the appropriate tables:
> psql -h db.xltfmrlaegzuuopvypxx.supabase.co -p 5432 -U postgres -d postgres
Password for user postgres:
psql (13.4, server 14.1)
WARNING: psql major version 13, server major version 14.
Some psql features might not work.
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
postgres=> \c postgres
psql (13.4, server 14.1)
WARNING: psql major version 13, server major version 14.
Some psql features might not work.
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
You are now connected to database "postgres" as user "postgres".
postgres=> \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+----------
public | Home | table | postgres
public | _prisma_migrations | table | postgres
(2 rows)
System information
- OS: Fedora 35
- Browser: Brave v1.41.96
- Version of Node.js: [16.16.0]
Additional context
Prisma schema:
// 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())
updatedAt DateTime @updatedAt
}
Issue Analytics
- State:
- Created a year ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Prisma - Supabase
This guide explains how to quickly connect the Postgres database provided by Supabase to a Prisma project. Prisma is an open source next-generation...
Read more >Prisma: 'npx prisma migrate dev' fails to connect with Supabase
So I went ahead to create a database on supabase, and grabbed the Connection string URL for the db it and added it...
Read more >Set up a free PostgreSQL database on Supabase to use with ...
This guide explains how to quickly connect the Postgres database provided by Supabase to a Prisma project. There are other services out ...
Read more >Help wanted: Error: P1001: Can't reach database server at "db ...
Hi all, I'm starting a new project and going through the docs to use supabase + prisma + React but despite following the...
Read more >Connection management (Guide) - Prisma
Databases can handle a limited number of concurrent connections. Each connection requires ... The way that you import and use the client does...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My issue was solved by working from home hehe. When I had my issue I was trying to connect from a hotel lobby, but from my own apartment it seems to work fine.
i am having the same issue using a hotel wifi, but it worked fine at home. if this info helps anyone 😃