PostgreSQL: Error: self-signed certificate in certificate chain (SSL Mode)
Error: self-signed certificate in certificate chain at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
Immediate Remediation
typescript
// In Node.js pg or database configuration, configure ssl rejection:
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false, // Allows cloud provider self-signed root certs
},
});
// Or in connection string:
// DATABASE_URL="postgresql://user:pass@host:5432/db?sslmode=no-verify"Root Cause Analysis
Cloud managed databases (Heroku, AWS RDS, Render, DigitalOcean) frequently use internally signed certificate authority certs that Node TLS rejects by default.
Verification & Guardrails
- For maximum security in production, supply the cloud provider CA cert bundle via ca: fs.readFileSync("ca.pem").
- Setting rejectUnauthorized: false bypasses host verification but preserves TLS transport encryption.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.