Skip to content
>_VibeUnstuck

self-signed certificate in certificate chain

Last verified:

The fix

self-signed certificate in certificate chain: the Postgres URL is missing TLS. On Vercel, use the pooled URL with sslmode=require. Leave TLS checks on.

  1. 1

    Use the provider’s pooled URL in the app

    Copy the pooler connection string from the dashboard. It should include sslmode=require. On Supabase that is the transaction pooler, port 6543. On Neon, use the host that includes -pooler. Do not point Vercel at localhost.

  2. 2

    Give Prisma two URLs

    The app uses the pooled URL. Migrations use a direct URL. For Supabase’s pooler, add pgbouncer=true so Prisma does not send statements the pooler will reject.

    datasource db {
      provider  = "postgresql"
      url       = env("DATABASE_URL")
      directUrl = env("DIRECT_URL")
    }
  3. 3

    Encode the password

    If the password contains reserved characters, percent-encode them in the URL. @ becomes %40. A wrong parse looks like a DNS or auth error, not a typo.

  4. 4

    Do not disable certificate checks

    sslmode=require is the normal fix. Setting rejectUnauthorized: false or NODE_TLS_REJECT_UNAUTHORIZED=0 turns off verification for the whole process. Use that only for a local custom CA you understand, not as the production setting.

Why it happens

Hosted Postgres (Supabase, Neon, RDS) expects TLS. A URL without sslmode=require fails the handshake or is rejected by pg_hba.conf. A password that contains @, :, or / and is not URL-encoded breaks the URL so the host looks wrong.

Serverless hosts open many short connections. The direct Supabase port 5432 is a poor fit there and is often IPv6-only. The transaction pooler (port 6543 on Supabase) is the URL the app should use. Migrations still need a direct URL, because pooled transaction mode does not support every migration statement. FATAL: Tenant or user not found is not a missing sslmode. The shared pooler could not match the host and username. Copy that string from Connect.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Failed to fetch: Supabase project paused. Failed to fetch with Supabase status 540 means the project is paused. Restore it in the dashboard and wait. An empty URL is a different error.

Prompt to paste back into your AI tool

Paste this above the error.

The app cannot connect to hosted Postgres. The error is one of: self-signed certificate, no pg_hba.conf entry, or can't reach database server.

Do not set NODE_TLS_REJECT_UNAUTHORIZED=0. Do not point the deployed app at localhost.

1. Use the provider’s pooled connection string with sslmode=require for DATABASE_URL.
2. If this is Prisma on Supabase, set directUrl to the direct connection and add pgbouncer=true on the pooled URL.
3. Percent-encode special characters in the password.
4. Do not change application queries. This is the connection string.

Common questions

+Why does the direct Supabase URL work on my laptop and fail on Vercel?

The direct host is often IPv6-only, and many serverless platforms do not reach it. Use the pooler connection string for the app. Keep the direct URL for migrations.

+Prisma migrate fails with prepared statement errors on the pooler. Why?

Transaction-mode poolers do not support all migration operations. Point directUrl at the non-pooled connection and run migrations through that.

Related errors