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.
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.
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.
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.
Error: EMFILE: too many open files, watch
EMFILE: fs.watch() limit exceeded
Error: Middleware next() called multiple times (next() invoked twice)
Express middleware next() called multiple times
Error: Worker failed to initialize (worker startup error)
Worker failed to initialize in Node.js
Error: EMFILE: too many open files, open 'file.txt'
EMFILE: too many open files
Error: cluster.fork() failed (cannot create child process)
cluster.fork() failed - Cannot create child process