How to fix Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported) in Node.js
This error occurs when Node.js tries to establish a TLS connection using a protocol version that the server doesn't support. TLS 1.0 and 1.1 are disabled by default in modern Node.js versions; ensure both client and server use TLS 1.2 or higher.
Quick fix
Fixes Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)
# Check running process
ps aux | grep node
# Check Node.js version
node --version
# Look for TLS-related environment variables
env | grep -i tls- Check your Node.js TLS configuration
- Update to TLS 1.2 or higher
- Specify TLS version in code (for connections)
- Update Node.js to a recent version
# Check running processps aux | grep node# Check Node.js versionnode --version# Look for TLS-related environment variablesenv | grep -i tlsError: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)
What this error means
The TLSV1_ALERT_PROTOCOL_VERSION error indicates a protocol version mismatch during TLS/SSL handshake. This happens when your Node.js application attempts to connect using a TLS version (commonly TLS 1.0 or 1.1) that the remote server refuses to accept. Modern servers enforce minimum TLS versions (usually 1.2 or 1.3) for security compliance, and outdated versions are disabled by default in Node.js to prevent insecure connections.
Typical symptoms
- HTTPS requests fail with TLSV1_ALERT_PROTOCOL_VERSION error
- HTTPS server connections are rejected by remote hosts
- npm install or package manager fails when downloading from registries
- API calls to third-party services fail intermittently
- Application crash during TLS handshake negotiation
Common causes
- Server enforces minimum TLS 1.2 or 1.3 but your Node.js is configured to use TLS 1.0 or 1.1
- Outdated TLS version flag (like --tls-v1.0) passed to Node.js on modern versions
- OpenSSL configuration mismatch between client and server security levels
- Using legacy servers that only support deprecated TLS versions while connecting from modern Node.js
- Environment variable or library forcing an old TLS version
How to fix "Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)"
Verify that you're not explicitly forcing an old TLS version. Look for command-line flags or environment variables that specify TLS versions:
# Check running process
ps aux | grep node
# Check Node.js version
node --version
# Look for TLS-related environment variables
env | grep -i tlsSet the minimum TLS version to 1.2 when starting your Node.js application. Remove any --tls-v1.0 or --tls-v1.1 flags:
# Instead of:
node --tls-v1.0 app.js
# Use:
node app.js # defaults to TLS 1.2+
# Or explicitly set:
node --tls-min-v1.2 app.jsWhen making outbound HTTPS connections, explicitly set the minimum TLS version in your code:
const https = require('https');
const options = {
hostname: 'api.example.com',
port: 443,
path: '/endpoint',
method: 'GET',
minVersion: 'TLSv1.2', // Enforce TLS 1.2+
maxVersion: 'TLSv1.3', // Allow up to TLS 1.3
};
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`);
});
req.on('error', (error) => {
console.error(error);
});
req.end();Modern Node.js versions (16+) have better TLS defaults. If running an old version, upgrade:
# Check current version
node --version
# Using nvm (Node Version Manager)
nvm install 18 # or 20, 22 for latest LTS
nvm use 18
# Using npm directly (updates npm, not Node)
npm install -g npm@latestIf running an HTTPS server, explicitly set supported TLS versions:
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.cert'),
minVersion: 'TLSv1.2',
maxVersion: 'TLSv1.3',
};
const server = https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('Secure connection');
});
server.listen(443);If you absolutely must use legacy TLS versions (not recommended), you may need to adjust OpenSSL security level:
# View OpenSSL version
openssl version
# For TLS 1.0 or 1.1 support, configure OpenSSL with lower security level
# This requires OpenSSL 1.1.0+ and should only be done for legacy systems
# Set via NODE_OPTIONS:
export NODE_OPTIONS='--openssl-config=/path/to/openssl.cnf'
node app.jsNote: Only use this for legacy systems; TLS 1.0/1.1 are deprecated and insecure.
Advanced notes
TLS 1.0 and 1.1 were officially deprecated by the IETF in 2021 due to security vulnerabilities. Major registries like npm have stopped accepting connections from clients using these versions. If connecting to a legacy server that only supports TLS 1.0/1.1, consider: (1) upgrading the remote server, (2) using a proxy that handles TLS negotiation, or (3) temporarily lowering OpenSSL security levels (SECLEVEL) only for that specific connection. The --tls-v1.0 flag no longer works in modern Node.js versions; use --tls-min-v1.0 if you have legitimate legacy needs, but this is strongly discouraged. Node.js 12 and earlier had different TLS defaults; upgrading to Node.js 16+ (current LTS) is the most straightforward solution.
Frequently asked questions
- What does "Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)" mean?
- The TLSV1_ALERT_PROTOCOL_VERSION error indicates a protocol version mismatch during TLS/SSL handshake. 1) that the remote server refuses to accept. js to prevent insecure connections.
- How do I fix "Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)"?
- This error occurs when Node.js tries to establish a TLS connection using a protocol version that the server doesn't support. TLS 1.0 and 1.1 are disabled by default in modern Node.js versions; ensure both client and server use TLS 1.2 or higher.
- What causes "Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)"?
- Server enforces minimum TLS 1.2 or 1.3 but your Node.js is configured to use TLS 1.0 or 1.1 Outdated TLS version flag (like --tls-v1.0) passed to Node.js on modern versions OpenSSL configuration mismatch between client and server security levels
- Is the "Error: TLSV1_ALERT_PROTOCOL_VERSION (TLS version not supported)" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐Node.js Official Documentation
- ๐Node.js TLS (SSL) Module Documentation(Official Docs)
- ๐
- ๐
- ๐