Node.js: Error: self-signed certificate in certificate chain (TLS handshake failure)
Error: self-signed certificate in certificate chain
at TLSSocket.onConnectSecure (node:_tls_wrap.js:1530:34)
at TLSSocket.emit (node:events:513:28)
Immediate Remediation
bash
export NODE_TLS_REJECT_UNAUTHORIZED=0
Root Cause Analysis
The server presented a self-signed certificate that Node.js cannot verify against its CA store, causing the TLS handshake to fail.
Verification & Guardrails
- Only use this in development; never disable TLS verification in production.
- For a permanent fix, add the self-signed certificate to the system trust store or use a CA-signed certificate.
- In Node.js code, you can also set `rejectUnauthorized: false` in the request options for specific requests.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.