skip to content

Cloudflare Realtime telehealth calls fail on a hospital network that allows only outbound TCP 443, though the app hands out TURN URLs on its own custom TURN hostname; why, and what fixes it?

level: seniorimportance: should knowfreq 14%

answer

  1. which transport listens on TCP 443
  2. a CNAME to turn.cloudflare.com
  3. custom hostnames lose one protocol
  4. what the firewall team must allow

basics

~10 s

On Cloudflare TURN, TCP 443 carries only TURN over TLS, and custom TURN hostnames do not support TLS. Hand out the turns:turn.cloudflare.com:443?transport=tcp URL, or have the firewall allow TURN's other ports.

solid answer

~40 s

Cloudflare TURN listens for **TURN over TCP** on 3478 and 80 and for **TURN over TLS** on 5349 and 443, so a firewall that allows only TCP 443 leaves one path open: `turns:` to port 443. A **custom TURN hostname**, a DNS-only CNAME pointing at `turn.cloudflare.com`, supports STUN, TURN over UDP and TURN over TCP but not TURN over TLS. The app's `turns:` URLs on its own name therefore cannot connect, and the UDP and plain TCP URLs are blocked by the firewall. The fix is to include `turns:turn.cloudflare.com:443?transport=tcp` (and 5349), as `generate-ice-servers` returns them, or to have hospital IT allow the other ports. If IT allowlists addresses, it must allow both IPv4 and IPv6 ranges, and the team must watch `turn.cloudflare.com`'s DNS for changes.

code

json · 15 lines
json
{
  "iceServers": [
    { "urls": ["stun:stun.cloudflare.com:3478"] },
    {
      "urls": [
        "turn:turn.telehealth.example:3478?transport=udp",
        "turn:turn.telehealth.example:3478?transport=tcp",
        "turns:turn.cloudflare.com:5349?transport=tcp",
        "turns:turn.cloudflare.com:443?transport=tcp"
      ],
      "username": "<GENERATED_USERNAME>",
      "credential": "<GENERATED_CREDENTIAL>"
    }
  ]
}

go deeper

for a junior

Recall the four TURN transports and that TCP 443 on Cloudflare TURN means TURN over TLS with a turns: URL.

for a middle

Explain how custom TURN hostnames work (DNS-only CNAME) and which protocol they lack.

for a senior

Diagnose the failure from the firewall policy and the rewritten URLs, and fix it without dropping the branded UDP and TCP entries.

for a principal

Set policy for customer networks: when to rely on TLS on 443, when to ask for an allowlist, and who owns the 14-day IP change watch.

## The symptom A telehealth app on the Cloudflare Realtime SFU works for patients at home and for clinicians on mobile data. On one hospital's network, clinicians never connect: ICE gathering finds no usable candidate pair and the connection ends in `failed`. Hospital IT says outbound traffic is limited to TCP port 443. The app's backend generates Cloudflare TURN credentials, but to keep its own branding it rewrites the URLs onto `turn.telehealth.example`, a CNAME to `turn.cloudflare.com`. Why relaying in general helps on such networks is a WebRTC NAT-traversal topic; the cause here is in how Cloudflare's TURN service maps transports to ports and hostnames. ## Cloudflare TURN's ports | Protocol | Address | Primary port | Alternate port | | --- | --- | --- | --- | | STUN over UDP | `stun.cloudflare.com` | 3478/udp | | | TURN over UDP | `turn.cloudflare.com` | 3478/udp | 443/udp | | TURN over TCP | `turn.cloudflare.com` | 3478/tcp | 80/tcp | | TURN over TLS | `turn.cloudflare.com` | 5349/tcp | 443/tcp | On **TCP 443 the only protocol is TURN over TLS**, written as a `turns:` URL. Plain TURN over TCP uses 3478 or 80. ## Custom TURN hostnames Cloudflare lets you serve TURN under your own name by creating a **CNAME** to `turn.cloudflare.com`. If the zone is on Cloudflare DNS, the record must be **DNS-only**, and pointing it at a resolved IP address is not supported. Custom hostnames work for STUN, TURN over UDP and TURN over TCP, but **not for TURN over TLS**. Putting those together: 1. The rewritten UDP URLs are blocked: the hospital allows no UDP. 2. The rewritten `turn:` TCP URLs on 3478 and 80 are blocked: only 443 is open. 3. The rewritten `turns:` URLs on 443 reach Cloudflare, but TURN over TLS is not offered on a custom hostname, so they cannot connect. Every candidate fails, which matches the symptom exactly. ## The fix - **Keep Cloudflare's own name for TLS.** Return the `iceServers` from `generate-ice-servers` unchanged, or at least keep `turns:turn.cloudflare.com:443?transport=tcp` and `turns:turn.cloudflare.com:5349?transport=tcp`. The branded hostname can stay on the UDP and TCP entries. - **Or open the ports.** If hospital IT can allow TURN over TCP on 3478 or 80, or UDP on 3478, the custom-hostname URLs work without TLS. - **Give SFU clients TURN in the first place.** On the Realtime SFU, the browser only relays if your backend put TURN entries into `iceServers`. RealtimeKit configures TURN itself, and its `overrides.forceRelay` init option makes clients prefer TURN over STUN. ## Why the rewrite looked harmless - At home and on mobile data, UDP works, so ICE succeeds on the branded UDP URLs and nobody notices the TLS entries are dead. - The failure only shows on networks where TLS on 443 is the **last remaining** path, as it often is on hospital and other locked-down networks. - Safe branding rule: rewrite STUN, UDP and plain TCP entries if you like, but always pass the `turns:` entries through on `turn.cloudflare.com`. ## When IT insists on an IP allowlist - Cloudflare lists the addresses to allow: `141.101.90.1/32` and `162.159.207.1/32` for IPv4, plus `2a06:98c1:3200::1/128` and `2606:4700:48::1/128` for IPv6. **Both families must be allowed.** - Cloudflare tries to keep these stable but does not guarantee them without an enterprise contract. Without one, the team must alert on changes to `turn.cloudflare.com`'s A and AAAA records and update the allowlist **within 14 days** of a change. - RealtimeKit clients also need their signaling and API domains, such as `api.realtime.cloudflare.com` and `socket-edge.realtime.cloudflare.com`, which the RealtimeKit allowlist page lists. ## Checking the fix - Join from a test machine behind the same policy and confirm that a relay candidate over TLS is selected; on such a network every other candidate should fail. - Keep a regression check in the backend's tests: every `iceServers` response must still contain a `turns:` URL on `turn.cloudflare.com` port 443, so a later "branding" change cannot quietly remove the one path locked-down sites depend on. - Watch TURN analytics, where usage appears within about 30 seconds, for traffic from that site. - Remember the billing side: relaying between Cloudflare TURN and the Realtime SFU is not charged twice, so forcing these clinicians through TURN adds no second egress charge.

  • Why not simply allowlist turn.telehealth.example in the hospital's firewall?
    The firewall's limit is the port, not the name. Even with the name allowed, TCP 443 on Cloudflare TURN carries only TURN over TLS, which a custom hostname does not support. Either the TLS entries use `turn.cloudflare.com`, or IT opens TURN over TCP or UDP on 3478 or 80.
  • What does relaying these clinicians through Cloudflare TURN add to the bill?
    TURN bills data sent from Cloudflare to the TURN client at $0.05 per GB, sharing the 1,000 GB monthly allowance with the SFU. Traffic between Cloudflare TURN and the Realtime SFU is not charged twice, so a relayed participant on an SFU call does not pay twice for the same media.

  • Cloudflare TURN accepts plain TURN over TCP on port 443.
  • A custom TURN hostname supports every protocol turn.cloudflare.com does.
  • The custom TURN CNAME should be proxied with the orange cloud for protection.
  • Allowlisting the two IPv4 addresses is enough for every client.
  • Cloudflare guarantees TURN's IP addresses never change on any plan.