Prisma + Supabase Error P1001
I kept getting Error P1001 (Can't reach database server) when using Supabase with Prisma. Here's how to troubleshoot and fix it.
I was trying to use Supabase's PostgreSQL database with Prisma for a project. I kept getting this error:
text
Error: P1001: Can't reach database server at `db.supabase.co`:`6543` Troubleshooting Steps:
- Verify Database URL: Double check your connection string in
.env. - Check Port: If you're using the pooled connection, ensure you're using port 6543. If direct, use 5432.
- Regenerate Prisma Client: Run
npx prisma generate. - Network Issues: Ensure your current network allows connections to the database port.
bash
npx prisma generate In many cases, simply regenerating the client or switching to a direct connection (port 5432) for the DIRECT_URL solves the problem.
Happy Hacking!