PrismaClientInitializationError: Can't reach database server
#155Error
PrismaClientInitializationError: Can't reach database server at `db.xxxx.supabase.co`:`5432`. Please make sure your database server is running at `db.xxxx.supabase.co`:`5432`.
Why it happens, and why this works
Prisma couldn't open a TCP connection to the host and port in DATABASE_URL. Common reasons: the database is paused (free Supabase projects pause; Neon sleeps), the host only has an IPv6 address and the network is IPv4-only (Supabase direct connections), the wrong port, a firewall, or the env var isn't loaded so a stale URL is used.
Fix
1. Make sure the database is running (unpause the Supabase project, wake the Neon branch). 2. Supabase: use the pooler connection string (Connect > Session or Transaction pooler, host *.pooler.supabase.com) instead of db.<ref>.supabase.co, which is IPv6-only. For the transaction pooler (port 6543) add ?pgbouncer=true, and set directUrl to the session pooler for migrations. 3. Add sslmode=require if the host needs SSL. 4. Print the host Prisma is actually using (without the password) to confirm the env var loaded.
Did it work?
No reports yetRelated fixes
Postgres: connection refused / could not connect to server (psycopg2, pg, Prisma)
#147psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused. Is the server running on that host and accepting TCP/IP connections? (also ECONNREFUSED 127.0.0.1:5432, Prisma P1001)
@prisma/client did not initialize yet. Please run "prisma generate"
#130Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server"
#150Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.