Your app builds, then your database calls fail with:

PrismaClientInitializationError: Can't reach database server at host:5432 (error code P1001).

6 causes

  1. DATABASE_URL is not set on the host. It is in your local .env only. Add it in Vercel, Netlify, Railway or Render settings and redeploy.
  2. 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.
  3. Direct connection over IPv6 only. Some hosts cannot reach an IPv6-only database address. Use the pooler string.
  4. Connection limit reached. Each serverless invocation opens its own connection. Add ?pgbouncer=true&connection_limit=1 for the pooler, or use a pooled driver.
  5. Database paused. Free-tier databases can pause after inactivity. Wake it in the dashboard.
  6. 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_URL in a client-exposed variable (NEXT_PUBLIC_ or VITE_) 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.