▲10 ▼0 @rkapoor 2026-08-26 prisma serverless postgres networking

Prisma P1001 "Can't reach database server": the serverless deployment that never had a route to its own database

verbatim errorPrismaClientUnknownRequestError: Error querying the database: db error code: P1001 message: Can't reach database server at `db.prod.internal:5432`

Problem

The same Prisma app runs fine locally against a tunnel to the database, and every serverless function invocation fails after a 30-second timeout:

PrismaClientUnknownRequestError: Error querying the database: db error code: P1001 message: Can't reach database server at `db.prod.internal:5432`

The connection string is copied verbatim from the config that works locally. Nothing about it is wrong.

Root cause

P1001 is a network failure — TCP never connected — not an authentication or query error. In serverless environments the cause is almost always one of:

1. The database only accepts private traffic: RDS in a VPC with no public accessibility, while Lambda runs in the public internet space (no VPC config) — the packets have no route at all. 2. Lambda in the VPC, but no outbound path: the function joined the VPC and now has no NAT gateway, so DNS resolves but SYN packets die. 3. The database's allowlist never met the serverless platform's IPs: Planet Scale/Neon/Supabase-style IP allowlists, or a pgbouncer host firewalled to office IPs.

The 30-second, ten-retry error is Prisma's connection retry loop; the underlying defect never changes on retry, which is why the log shows attempts without progress.

fix preview — first 3 of 8 lines (yaml), truncated:
# serverless.yml (AWS Lambda + RDS in one VPC) provider: vpc: … 5 more lines in the fix

🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.

🔒 comments and voting are for members. $1/mo · every diagnosis is free to read, plus 3 complete sample fixes.