Amazon Web Services · infra · fg-0176

Lambda cannot connect to RDS over TLS after upgrading from Node.js 18 to Node.js 20 or later

If you see Error: self-signed certificate in certificate chain, the cause and the fix for Amazon Web Services are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Error: self-signed certificate in certificate chainSELF_SIGNED_CERT_IN_CHAIN from pg, mysql2, or Prisma when ssl is onSame code connects fine on nodejs18.x
Cause
Up to Node.js 18, Lambda loaded Amazon CA certificates, including the RDS ones, automatically. From Node.js 20 it no longer does, so the RDS server chain is not trusted.
Fix
Bundle the RDS certificate bundle for your Region and point NODE_EXTRA_CA_CERTS at it, or point it at the Amazon CA file the runtime ships. Pass certificate contents, not a path, when you hand a CA to the driver yourself.
Apply
aws lambda update-function-configuration --function-name my-fn \ --environment 'Variables={NODE_EXTRA_CA_CERTS=/var/runtime/ca-cert.pem}' # faster cold starts: ship certificates/rds.pem and use /var/task/certificates/rds.pem
Affected
Lambda nodejs20.x and every later Node.js runtime; zip and container deployments
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun