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

  1. Remove the transport option (it defaults to 'tcp') or set it explicitly to 'tcp'
  2. For Unix-socket targets use Deno.connect({ transport: 'unix' }) without TLS
  3. 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

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


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/667ad56cf6e43015. Report an issue: GitHub.