denoland/deno · error · TypeError
Unsupported transport: '${transport}'
Error message
Unsupported transport: '${transport}' What it means
Deno.connectTls defaults transport to 'tcp' and immediately throws this TypeError for any other value. TLS in Deno is implemented only over TCP - there is no TLS over Unix sockets and no DTLS (TLS over UDP).
Source
Thrown at ext/net/02_tls.js:69
return op_tls_peer_certificate(this.#rid, detailed);
}
}
async function connectTls({
port,
hostname = "127.0.0.1",
transport = "tcp",
caCerts = [],
alpnProtocols = undefined,
keyFormat = undefined,
cert = undefined,
key = undefined,
unsafelyDisableHostnameVerification = false,
autoSelectFamily = true,
autoSelectFamilyAttemptDelay = 250,
}) {
if (transport !== "tcp") {
throw new TypeError(`Unsupported transport: '${transport}'`);
}
const keyPair = loadTlsKeyPair("Deno.connectTls", {
keyFormat,
cert,
key,
});
// TODO(mmastrac): We only expose this feature via symbol for now. This should actually be a feature
// in Deno.connectTls, however.
const serverName = arguments[0][serverNameSymbol] ?? null;
const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_tls(
{ hostname, port },
{ caCerts, alpnProtocols, serverName, unsafelyDisableHostnameVerification },
keyPair,
{ autoSelectFamily, autoSelectFamilyAttemptDelay },
);
localAddr.transport = "tcp";
remoteAddr.transport = "tcp";View on GitHub (pinned to 89f33cbef2)
Solutions
- Remove the transport option (it defaults to 'tcp') or set it explicitly to 'tcp'
- For Unix-socket targets use Deno.connect({ transport: 'unix' }) without TLS
- If you need TLS on a local socket, terminate TLS at a local TCP front (e.g. stunnel) and connect plain
Example fix
// before
await Deno.connectTls({ transport: "unix", path: "/var/run/tls.sock" });
// after
await Deno.connectTls({ hostname: "example.com", port: 443 }); Defensive patterns
Strategy: validation
Validate before calling
function assertTlsTransport(opts: { transport?: string }): void {
if (opts.transport !== undefined && opts.transport !== "tcp") {
throw new Error(
`connectTls only supports transport 'tcp' (TLS over Unix/UDP is unsupported), got: ${String(opts.transport)}`,
);
}
} Type guard
function isTlsTransport(t: unknown): boolean {
return t === undefined || t === "tcp";
} Prevention
- Do not reuse generic connect option builders for connectTls
- Keep TLS targets as hostname/port pairs, not sockets
- Terminate TLS locally (stunnel or similar) if you must bridge to a Unix socket
When it happens
Trigger: Deno.connectTls({ transport: 'unix', path: '/run/s.sock' }); transport: 'udp'; any truthy value other than 'tcp'.
Common situations: Trying to reach TLS services over Unix sockets (Postgres, Redis behind local proxies); shared option builders reused for both connect and connectTls.
Related errors
- Invalid port: '${maybePort}'
- Invalid port: ${maybePort}
- Invalid port (out of range): ${maybePort}
- If "keyFormat" is specified, it must be "pem": received "${k
- If `cert` is specified, `key` must be specified as well for
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/667ad56cf6e43015.
Report an issue: GitHub.