Your app builds, then your database calls fail with:
PrismaClientInitializationError: Can't reach database server at host:5432 (error code P1001).
6 causes
- DATABASE_URL is not set on the host. It is in your local
.envonly. Add it in Vercel, Netlify, Railway or Render settings and redeploy. - Wrong host or port. A serverless host needs the pooled connection string (for Supabase, the pooler on port 6543), not the direct one on 5432.
- Direct connection over IPv6 only. Some hosts cannot reach an IPv6-only database address. Use the pooler string.
- Connection limit reached. Each serverless invocation opens its own connection. Add
?pgbouncer=true&connection_limit=1for the pooler, or use a pooled driver. - Database paused. Free-tier databases can pause after inactivity. Wake it in the dashboard.
- IP allow list. Your database only accepts listed IPs, and your host's IPs are not on it.
The security side
The usual unsafe fixes:
- Opening the database to every IP (
0.0.0.0/0) so the connection stops failing. Prefer the provider's pooler, which is built for serverless, and keep a strong password. - Putting
DATABASE_URLin a client-exposed variable (NEXT_PUBLIC_orVITE_) because the server code could not read it. That string contains your database password. If it ever shipped in a bundle, rotate the password now. - Pasting the full connection string into an AI chat or a public issue to get help. Redact the password first.
Check what shipped
Search your built output and your live site's JavaScript for postgres:// or postgresql://. If you find it, the credential is public.
An outside view
ProofForge at proofforge.live runs a free public-side scan of AI-built apps. It never signs in, and it can flag secret-shaped strings such as connection strings in what a visitor can download. It cannot see your host settings or your database firewall.

