Why Some Networks Refuse Direct WebRTC Connections

By ShareDrop.org Engineering · Published · Updated

Sometimes two devices connect instantly and directly. Sometimes the very same app, the very same devices, end up on a relay, or fail entirely, just because one of them moved to an office network. The difference is almost always one of the following network conditions.

1. Ordinary NAT (usually fine)

A home router translating private addresses to one public address is the normal case. WebRTC's hole punching (STUN) handles most home routers because they use the same public port for a given internal socket regardless of destination, so an address learned from the STUN server also works for the peer.

2. Symmetric NAT (hole punching dies)

A symmetric NAT allocates a different public port for every destination you contact. The port your peer learned from signaling is not the port your router will use to talk to that peer: probes miss, pairs never validate, and ICE falls back to relay. Symmetric NAT is common on corporate firewalls and some mobile carriers.

3. Carrier-grade NAT (two layers deep)

Many ISPs, mobile networks especially, put customers behind a second, shared NAT layer (CGNAT). Your router's “public” address is itself private. Two CGNAT users can often still connect if at least one side's mapping behaves classically, but the failure rate rises sharply, and CGNAT + symmetric behaviour is a guaranteed relay.

4. UDP blocked (the corporate classic)

WebRTC strongly prefers UDP. Plenty of enterprise, campus and hotel networks allow only TCP ports 80/443. In that world nothing about hole punching matters — no UDP, no direct WebRTC. The escape hatch is TURN over TCP, and ultimately TURN over TLS on port 443, which is indistinguishable from ordinary HTTPS traffic to most middleboxes. Expect noticeably higher latency and somewhat lower throughput than UDP.

5. Interception and lockdown

Networks that man-in-the-middle TLS (some corporate proxies) or block unknown endpoints entirely can defeat even TURN/TLS. At that point the transfer honestly cannot proceed on that network: a tool that claims otherwise is bluffing. A phone hotspot is the standard workaround.

A note on local networks

Counterintuitively, “same network” can also fail: guest Wi-Fi with client isolation blocks devices from seeing each other, and modern browsers hide local addresses behind mDNS names (xxxx.local) for privacy, which some networks and OS permission systems refuse to resolve. In those cases devices standing a meter apart still connect via STUN reflexive addresses or a relay. The app's connection badge (reading it) tells you what actually happened.

6. Local-network permission and hidden addresses

Two newer causes live on the device rather than in the network. Modern browsers do not put your local address into the connection setup; they use a random name that the other device resolves with multicast DNS, which only works on the same network, and only if that network passes multicast. On macOS and iOS, the operating system also asks each app for permission to use the local network the first time; a browser or app that was denied gathers no usable local candidate at all. Both produce the same symptom: two devices side by side connect Internet direct through the router's public side, or via a relay, instead of LAN direct. The transfer works; it is just not taking the short path.

How often each one shows up

Ranked roughly from most to least common, with the quickest way to recognise each:

CauseHow to recognise itWhat the transfer does
Guest Wi-Fi with client isolationDevices on the same network show Encrypted relay; nearby-share tools see nothingRelays through the venue's uplink (details)
Mobile carrier CGNATPhone on cellular; badge says relay; the same phone on Wi-Fi says directRelays over IPv4; direct if both sides have IPv6
VPN on one or both devicesRelay on the same desk; pausing the VPN flips it to directRelays, or fails if the VPN blocks WebRTC (details)
Corporate UDP blockOffice network; long “connecting”; then relayRelays over TCP — slower, but completes
Symmetric NAT at a home ISPDirect works with some peers and not othersRelays with the peers it cannot punch to
mDNS or local-network permissionInternet direct between two devices on one Wi-FiWorks, via the router's public side
Double NATRouter's WAN address is private (10.x, 192.168.x, 100.64–127.x)Usually still direct; relays if either layer is symmetric
Full lockdown or TLS interceptionNothing connects, even the relayCannot proceed on that network

Diagnosing it in two minutes

  1. Read the badge. LAN direct means none of this applies. Internet direct on the same Wi-Fi points at cause 6. Encrypted relay points at everything else; the transfer still works.
  2. Pause any VPN on both devices and retry. If the badge changes, that was it.
  3. Put one device on a phone hotspot and retry. If it now connects directly, the original network was isolating, blocking UDP or behind CGNAT. If it still relays, the other device's network is the constraint.
  4. If nothing connects at all, not even via relay, the network is blocking unknown destinations. A hotspot for the whole transfer is the only fix short of talking to whoever runs the network.

The cause that is really a cure: IPv6

On IPv6 there is no address translation, so there is no port to guess and no mapping to expire; the router's firewall still drops unsolicited packets, but the connectivity check itself opens it. When both devices have working IPv6 (common on mobile carriers, less so on fixed lines), the direct IPv6 pair usually wins even where the IPv4 pairs would have failed. Two phones on IPv6-capable carriers can connect directly despite both being behind CGNAT. A peer without IPv6 forces everything back to the IPv4 rules above (the details).

Things that do not cause it

What to ask a network administrator for

If an office network blocks transfers and you have someone to ask, the request is small and specific: allow outbound UDP to port 3478 (STUN and TURN), or at minimum outbound TCP to 3478 and 443 to the relay's address. No inbound rule is needed (everything is initiated from inside), and no port forwarding. Client isolation on a guest network is usually there on purpose and will not be lifted; a hotspot is the honest answer there.

How long a failure takes to show

Because a blocked path looks identical to a slow one until a timer runs out, a transfer on a hostile network spends longer “connecting” than a working one spends transferring a small file. Direct candidate pairs are each retried for several seconds before being abandoned; the relay pair is tried in parallel and usually rescues the connection within two or three seconds of the code being entered. A failure message after thirty seconds or so means every path, relay included, was refused. Retrying immediately on the same network rarely helps (nothing has changed), but retrying after switching one device to a hotspot changes everything, because it gives ICE a new set of candidates to try.

What this means practically

Standards behind this article