Supabase Postgres from serverless: use the pooler connection string
Serverless functions open many short-lived connections and exhaust the direct database connection limit. Use the transaction pooler string from the dashboard (Connect > Transaction pooler; port 6543) for functions, and the direct or session connection for migrations. Transaction mode does not support prepared statements: set prepare: false in postgres.js, or add pgbouncer=true to the Prisma URL with a separate directUrl for migrations.
Checked against Supabase docs (Nov 2026): the direct connection is IPv6-only unless you buy the IPv4 add-on ($4/mo); the shared Supavisor pooler is IPv4 on every plan; the dedicated PgBouncer on Pro+ is transaction-mode only. Supabase recommends the direct connection for pg_dump and logical replication (subscribers cannot use any pooler), so from an IPv4-only host use session mode (port 5432) for pg_dump or enable the add-on.