ProjectStack
npm

Error: self-signed certificate in certificate chain

Node.js rejected an HTTPS connection because the server's SSL certificate is self-signed or signed by a certificate authority that Node.js doesn't trust. This is common in corporate networks with SSL inspection.

Common causes

  • A corporate network or proxy performs SSL inspection using its own CA certificate
  • You're connecting to a development or staging server with a self-signed cert
  • The CA certificate for an internal server hasn't been added to Node.js's trusted store
  • npm is being proxied through a tool that intercepts HTTPS traffic

How to fix it

  1. For corporate CA: add the certificate to Node.js: NODE_EXTRA_CA_CERTS=/path/to/cert.pem npm install
  2. For npm registry issues: npm config set cafile /path/to/corporate-ca.pem
  3. As a last resort for development only (never production): NODE_TLS_REJECT_UNAUTHORIZED=0 npm install
  4. Ask your IT/network team for the corporate CA certificate to add properly

Example

Error: self-signed certificate in certificate chain at TLSSocket.onConnectSecure (node:_tls_wrap:1659:34) at TLSSocket.emit (node:events:514:28)

Running npm install behind a corporate proxy that performs HTTPS inspection

Have a different error?

Paste any error message into the Error Translator to get an instant explanation.