- Symptom
- Error: self-signed certificate in certificate chainAdding ssl: { rejectUnauthorized: false } or a ca next to connectionString changes nothing
- Cause
- pg parses sslmode from the connection string and the result replaces the ssl option you passed instead of merging with it. In pg-connection-string, prefer, require, and verify-ca all mean full certificate verification unless uselibpqcompat=true is set, which differs from libpq.
- Fix
- Drop sslmode from the URL and configure ssl in code, or parse the URL yourself and merge the ssl settings before creating the pool.
- Apply
import pg from 'pg' import parseConnectionString from 'pg-connection-string' const cfg = parseConnectionString(process.env.DATABASE_URL) cfg.ssl = { ca: process.env.DATABASE_CA_CERT } const pool = new pg.Pool(cfg)- Affected
- pg 8.x with pg-connection-string 2.x, as of October 2026 (merge issue open since 2021)
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders