denoland/deno · error · TypeError
ERR_TLS_PROTOCOL_VERSION_CONFLICT
ERR_TLS_PROTOCOL_VERSION_CONFLICT
Error message
TLS protocol version ${minVersion || maxVersion} conflicts with secureProtocol secureProtocol What it means
ERR_TLS_PROTOCOL_VERSION_CONFLICT from _tls_common's getProtocolRange(): TLS socket options accept either the legacy secureProtocol method selector (e.g. 'TLSv1_2_method') or the modern minVersion/maxVersion range — never both. If secureProtocol is set and minVersion or maxVersion is also truthy, the conflict is thrown before any other validation, echoing the offending version string.
Solutions
- Delete secureProtocol and keep minVersion/maxVersion (the modern style)
- Or keep secureProtocol and remove minVersion/maxVersion entirely
- Best modern default: minVersion: 'TLSv1.2', maxVersion: 'TLSv1.3'
Example fix
// before
tls.connect({ secureProtocol: 'TLSv1_2_method', minVersion: 'TLSv1.2', host }); // throws
// after
tls.connect({ minVersion: 'TLSv1.2', maxVersion: 'TLSv1.3', host }); Defensive patterns
Strategy: validation
Validate before calling
if (opts.secureProtocol && (opts.minVersion || opts.maxVersion)) {
throw new Error('secureProtocol cannot be combined with minVersion/maxVersion');
} Prevention
- Standardize on minVersion/maxVersion in a shared TLS config helper
- Lint against new uses of secureProtocol in code review
When it happens
Trigger: tls.connect({ secureProtocol: 'TLSv1_2_method', minVersion: 'TLSv1.2' }); https.createServer({ secureProtocol: 'SSLv23_method', maxVersion: 'TLSv1.3' }, handler);
Common situations: Legacy codebases carrying secureProtocol that receive a TLS-hardening patch adding minVersion; merged configs combining old and new styles; guidance copied from docs of different eras.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
Related errors
- ERR_INVALID_ARG_TYPE
- ERR_TLS_ALPN_CALLBACK_WITH_PROTOCOLS
- ERR_TLS_INVALID_PROTOCOL_VERSION
- Bad cluster.schedulingPolicy
- Both 'cert' and 'key' must be provided to enable HTTPS
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/0dd96aea98d01fbc.
Report an issue: GitHub.
Appendix: source
Thrown at ext/node/polyfills/_tls_common.ts:297
return ArrayPrototypeFilter(
ArrayPrototypeMap(val, (v: any) => toStringOrUndefined(v)!),
Boolean,
);
}
return toStringOrUndefined(val);
}
function getProtocolRange(
options: any,
): { minVersion: string; maxVersion: string } {
let minVersion = getDefaultMinVersion();
let maxVersion = getDefaultMaxVersion();
if (options.secureProtocol) {
// If secureProtocol is set, minVersion/maxVersion must not also be set.
// Node raises this conflict before validating the protocol method string.
if (options.minVersion || options.maxVersion) {
throw new ERR_TLS_PROTOCOL_VERSION_CONFLICT(
options.minVersion || options.maxVersion,
"secureProtocol",
);
}
const range = kProtocolMap[options.secureProtocol];
if (!range) {
if (
options.secureProtocol === "SSLv2_method" ||
options.secureProtocol === "SSLv2_client_method" ||
options.secureProtocol === "SSLv2_server_method"
) {
throw new ERR_TLS_INVALID_PROTOCOL_METHOD("SSLv2 methods disabled");
}
if (
options.secureProtocol === "SSLv3_method" ||
options.secureProtocol === "SSLv3_client_method" ||
options.secureProtocol === "SSLv3_server_method"View on GitHub (pinned to 9ad36f7a2c)