Neon Postgres: Serverless Connection Pool Starvation & Timeout
PrismaClientInitializationError: Can't reach database server at ep-patient-hill-pooler.c-10.aws.neon.tech:5432. Timed out after 10000ms.
Immediate Remediation
typescript
# 1. Use the -pooler connection endpoint (port 5432 with PgBouncer):
DATABASE_URL="postgresql://user:pass@ep-project-pooler.c-10.aws.neon.tech/neondb?sslmode=require&connection_limit=5"
# 2. In serverless / edge runtime, cache the client globally:
const globalForDb = globalThis as unknown as { pool: Pool };
export const pool = globalForDb.pool || new Pool({ connectionString: process.env.DATABASE_URL, max: 5 });
if (process.env.NODE_ENV !== 'production') globalForDb.pool = pool;Root Cause Analysis
Serverless functions spawned multiple un-pooled database connections across lambdas, exhausting the maximum client connection limit on Postgres.
Verification & Guardrails
- Always use Neon pooled endpoints (-pooler.c-10) instead of unpooled endpoints in serverless apps.
- Keep max pool connections per function instance capped at 5 or lower.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.