Can't connect to supabase using prisma

npx prisma migrate dev --name init
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "aws-0-us-west-1.pooler.supabase.com:5432"

Error: P1001: Can't reach database server at `aws-0-us-west-1.pooler.supabase.com:5432
npx prisma migrate dev --name init
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "aws-0-us-west-1.pooler.supabase.com:5432"

Error: P1001: Can't reach database server at `aws-0-us-west-1.pooler.supabase.com:5432
5 Replies
Prisma AI Help
Prisma AI Help•2w ago
You selected the bot's instantaneous insights. Let me compile your answer right away! This is a common issue when trying to connect Prisma to a Supabase database. Based on the knowledge sources, here are a few steps you can try to resolve this problem: 1. Update your database connection strings: Add both a DATABASE_URL and a DIRECT_URL to your .env file. The DIRECT_URL is used for migrations. Your .env file should look something like this:
DATABASE_URL="postgresql://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
DIRECT_URL="postgresql://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:5432/postgres"

DATABASE_URL="postgresql://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
DIRECT_URL="postgresql://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:5432/postgres"

Note that the DATABASE_URL uses port 6543, while the DIRECT_URL uses port 5432. 2. Update your schema.prisma file to include both URLs:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

3. Make sure you're using the correct password and project reference ID from Supabase. 4. Try adding a connection timeout to your DATABASE_URL:
DATABASE_URL="postgresql://...?connect_timeout=300"

DATABASE_URL="postgresql://...?connect_timeout=300"

5. If you're using a VPN, try disconnecting it as it might interfere with the connection. If these steps don't resolve the issue, you may want to check if you can connect to the database using psql or another PostgreSQL client to ensure the problem is not with the database itself. For more detailed information and troubleshooting steps, you can refer to these resources: Github Issue: db pull can't connect to supabase when using "[...].pooler.supabase.com:5432" Github Issue: Unable to reach database server at aws-0-us-east-1.pooler.supabase.com:5432 using Prisma migrate dev Prisma Docs: Supabase Connection Guide If you're still encounter ing issues after trying these steps, you may need to reach out to Supabase support or create a new issue on the Prisma GitHub repository with more details about your specific setup. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
i_lost_to_loba_kreygasm
anyone out there ? HELP
RaphaelEtim
RaphaelEtim•2w ago
Hi @i_lost_to_loba_kreygasm Are you using both the pooled and direct connection? Also, does your schema.prisma file look like?
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}
i_lost_to_loba_kreygasm
thank you for getting back to me , apparently numbers in password causes issue i solved it
RaphaelEtim
RaphaelEtim•2w ago
Great to hear you solved it

Did you find this page helpful?