Prisma P1001: Can't reach database server
Prisma on Vercel says P1001 Can't reach database server? That host and port are not accepting a connection. For Supabase, Prisma's serverless URL uses the transaction pooler on port 6543.
Reviewed October 18, 2026
What it means in plain English
Prisma Client throws PrismaClientInitializationError when the engine starts and the connection is created. That is prisma.$connect() or the first query. Code P1001 is this message: Can't reach database server at {database_host}:{database_port} Please make sure your database server is running at {database_host}:{database_port}.
Prisma's Postgres guide, for Neon and Supabase, tells you to use two URLs. The runtime URL is the pooler on port 6543 with ?pgbouncer=true. The CLI URL is a direct connection on port 5432. For Supabase, the direct host is db.[project-ref].supabase.co:5432. The transaction pooler is port 6543 with ?pgbouncer=true. The session pooler is port 5432 on the pooler host.
A missing DATABASE_URL is a different failure. With the pg driver adapter, Prisma says the usual symptom is SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string, because pg then has no connection string.
Likely causes
- The Vercel env var still points at
localhost, or at a host and port that are not the Supabase pooler. - The runtime URL uses the direct port 5432 on
db.[project-ref].supabase.cofrom a serverless function. Prisma's serverless example uses port 6543 andpgbouncer=truefor that URL. prisma.config.tsand the app read the same variable, so migrations and the serverless function are sharing a URL that only one of them can use.
How to fix it, step by step
- Read the host and port in the P1001 line. That is the address Prisma could not open. It has to match the Supabase connection string you intended.
- On Vercel, set the runtime URL to the transaction pooler, port 6543, with
?pgbouncer=true, as in Prisma's serverless example:postgres://user:pass@host-pooler:6543/db?pgbouncer=true. - Set a second variable for the CLI, port 5432, on the direct host
db.[project-ref].supabase.co. Pointprisma.config.tsat that variable:datasource.urlisenv("DIRECT_URL"). Prisma says the CLI uses the direct connection. - Redeploy after the env vars change. A local
.envis not the Vercel function's environment. - If the error becomes
prepared statement "s0" already exists, the host is reachable and the pooler mode is the next fix. See Prisma: prepared statement "s0" already exists.
How to check it worked
- The Vercel function log no longer shows P1001.
- The first query returns rows.
prisma migratestill uses the direct 5432 URL, and the app uses the 6543 URL.
Sources
Related fixes
More Database connections fixes
Keep going on your own.
The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.