All Recipes
StarVerified Developer Solution • 100% Offline
X.509 Certificate & CSR Decoder

Fix "unable to get local issuer certificate" in Node.js

Solve UNABLE_TO_GET_ISSUER_CERT_LOCALLY errors when making requests to HTTPS endpoints.

The Problem (Error Root Cause)Exception

Your HTTP request fails with `UNABLE_TO_GET_ISSUER_CERT_LOCALLY`. Node.js cannot verify the server's SSL certificate because it lacks the root CA or the server didn't send the intermediate certificates.

Identified via runtime validation & stack traces
The Solution (Step-by-Step Fix)Verified

Avoid setting `NODE_TLS_REJECT_UNAUTHORIZED=0`. Instead, fix the server's certificate chain (include the intermediate certs), or manually supply the custom root CA to your Node.js HTTPS agent.

Deterministic, non-destructive resolution

Code Standard: Bad Pattern vs Verified Fix

Live Syntax
Anti-Pattern vs Verified Fix
1// ❌ Bad: Disabling TLS verification globally
2process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
3
4// ✅ Good: Passing the custom CA
5const agent = new https.Agent({ ca: fs.readFileSync('custom-ca.pem') });
6axios.get('https://internal.api', { httpsAgent: agent });

Test and resolve this using X.509 Certificate & CSR Decoder

Execute directly in your browser memory. Zero API keys, zero network tracking, completely client-side.

Launch X.509 Certificate & CSR Decoder

Frequently Asked Questions

Q:Why does this work in Chrome but fail in Node?

Browsers dynamically fetch missing intermediate certificates (AIA fetching) and have larger trust stores. Node.js is strict and only trusts bundled CAs.

Q:How do I inspect my certificate chain?

Use our X.509 Certificate Decoder to inspect your server's PEM files.

Related Troubleshooting Guides

View Directory