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
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 atlocalhost. - 2
Give Prisma two URLs
The app uses the pooled URL. Migrations use a direct URL. For Supabase’s pooler, add
pgbouncer=trueso Prisma does not send statements the pooler will reject.datasource db { provider = "postgresql" url = env("DATABASE_URL") directUrl = env("DIRECT_URL") } - 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
Do not disable certificate checks
sslmode=requireis the normal fix. SettingrejectUnauthorized: falseorNODE_TLS_REJECT_UNAUTHORIZED=0turns 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
- Failed to fetch: Supabase project pausedFailed 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.CursorLovableBoltSupabaseAuthOct 19, 2026
- @prisma/client did not initialize yet@prisma/client did not initialize yet. Run prisma generate so the client matches the schema. Generate does not migrate. Restart after it succeeds.CursorBoltReplitPrismaPostgresOct 14, 2026
- sorry, too many clients alreadyPostgres or the pooler refused another connection. On Vercel, each warm function was opening its own pool, and the database ran out.Cursorv0BoltPostgresPrismaOct 27, 2026
- FATAL: Tenant or user not foundFATAL: Tenant or user not found. The shared pooler could not match this host and username to a project. Copy the Connect string. The user is postgres.[PROJECT-REF]. Do not invent the host, and do not reset the password for this sentence.CursorLovableBoltSupabasePostgresNov 5, 2026
- Invalid API keyInvalid API key. Supabase received a key this project does not accept. Copy the publishable key, or the legacy anon key, from the same project as the URL. No API key found in request means the header was missing.CursorLovableBoltSupabaseNext.jsNov 6, 2026