prisma: `db pull` can't connect to supabase when using "[...].pooler.supabase.com:5432"
Bug description
I’ve been trying to connect Prisma with Supabase for a while now but I keep getting an error whenever I try to run these commands:
npx prisma db pull
npx prisma migrate dev --name init
this is the error:
User postgres.[id] was denied access on the database postgres.public
Database Url:
DATABASE_URL="postgres://postgres[.id]:[password]@aws-0-us-east-1.pooler.supabase.com:5432/postgres"
I’ve been tinkering with the database Url to try to find a way through this error by using a username in the database url but I get this error when i run npx prisma db pull :
✖ Introspecting based on datasource defined in prisma\schema.prisma
Error: FATAL: Tenant not found
How to reproduce
I have tried deleting the database, granting the user connect and usage privileges but I keep getting the same error.
Expected behavior
No response
Prisma information
// 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")
}
Environment & setup
- OS: Windows 10 Pro
- Database: PostgreSQL
- Node.js version: v20.7.0
Prisma Version
Environment variables loaded from .env
prisma : 5.5.2
@prisma/client : 5.5.2
Current platform : windows
Query Engine (Node-API) : libquery-engine aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine : schema-engine-cli aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a (at node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm : @prisma/prisma-schema-wasm 5.5.1-1.aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a
Default Engines Hash : aebc046ce8b88ebbcb45efe31cbe7d06fd6abc0a
Studio : 0.494.0
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 21 (9 by maintainers)
I was getting a similar error
I was using Supabase as my provider and I found the issue to be with the connection URL that Supabase provides.
On https://supabase.com/dashboard/project/[your-supabase-project], Supabase has a
Connectbutton that opens a modal which gives you info on how to connect to your Supabase. UnderORMtab in that modal, the value ofDATABASE_URLis incorrect. Specifically the AWS region. Whatever region you chose when you created the project, the region inDATABASE_URLis alwaysaws-0-eu-central-1which is incorrect. I changed this region to the region I was using and stopped getting this error.This was really helpful 👍🏾 in addition to this, I had to replace the
DIRECT_URLreferenced in theORMstab:with the one referenced in the
Connection Stringtab:Now everything is working ✅
@RoyJumah I think
User postgres.[id] was denied access on the database postgres.publicmight be a new error message, though it’s actually expected that Migrate and Introspection have issues with the pooled connection string in general.You must use a direct connection string for Introspection & Migrate. Example
See https://www.prisma.io/docs/guides/database/supabase#specific-considerations
Could you try that and let us know how it goes?
I’m experiencing the same issue, even with the additional
pgbouncer=truefield. I was able to run migrate the first time, but I get the following error for all subsequent requests to the dbWhat do you mean by that?
Note I tried to reproduce to see the error message
I could reproduce by changing the port, the default port for the pooler is
6543. It’s also the same value in this project on Supabase. When changing it to5432in the connection string only, then the error message is the same as this issue.Thanks, @Jolg42 .This fixed it 😀. I will take my time to go through the documentation.