By Maryna Poplavska, Lead Project Manager · Last updated 19 November 2026
A TURN server relays WebRTC media when two endpoints can’t reach each other directly. A STUN server only tells a client its public address, and ICE is the procedure that tries direct paths first and falls back to the relay. coturn is an open-source server that does both. In production, the questions are how much of your traffic ends up on the relay, what that costs, and what breaks first. In rescue work, the problem often arrives as: “It works on our Wi-Fi but fails for some customers.”
Key takeaways
- STUN is not a relay. A STUN-only config leaves nothing to fall back on when a network blocks the direct path.
- There is no universal relay share. Measure yours per customer network, and count the calls that never connected.
- Size coturn on bandwidth first. Relay egress is what the relay sends: each relayed participant’s receive bitrate, plus their send bitrate when the far end (a peer or your SFU) isn’t on the same relay.
- Read the metering definition before the rate. Twilio meters what the client sent and received; Cloudflare meters only what it sends to the client.
- Offer TURN over UDP, TCP and TLS. Some networks block UDP; some allow only port 443.
- An unrestricted relay is a way into your network. Deny internal ranges, use time-limited credentials, patch and isolate.
CTOs and budget owners: go to what a TURN server costs and managed, self-hosted or built in. Engineers: the failure table and sizing.
What do STUN, TURN and ICE each do, and which one is failing?
ICE (RFC 8445) gathers candidate addresses, pairs them and runs connectivity checks until a pair works.

The candidate type tells you which server did what:
- host: “obtained by binding to a specific port from an IP address on the host”.
- server-reflexive (
srflx): the address a NAT allocated, as a STUN server saw it. Peer-reflexive (prflx) is a NAT address learned from a connectivity check’s source instead. - relayed (
relay): “obtained from a relay server, such as a TURN server”.
RFC 8445 ranks relayed candidates last: its recommended type preference for them is 0, which means “candidates of this type will only be used as a last resort.”
So no srflx may mean STUN is missing or unreachable, or a network restriction; on its own it doesn’t prove UDP is blocked, and host candidates can still connect. No relay means TURN is missing, unreachable or refusing your credentials. The TURN standard, RFC 8656, says relaying “comes at a high cost to the provider of the TURN server”, so use it “only when a direct communication path cannot be found.”
How much of your traffic will actually use the relay?
Nobody can tell you in advance. Tsahi Levent-Levi’s TURN explainer on BlogGeek.me (November 2025) cites “common lore” that around 80% of connections resolve without a relay; in a 2022 reply he has seen “anything between 0-50% of TURN relay.” Neither is a benchmark.
Your share depends on where users connect from: home broadband and hospital networks can sit at opposite ends. RFC 8835 §3.4 ties TURN to NATs with endpoint-dependent mapping (often called symmetric NAT) and to “firewalls that block all UDP traffic”.
Measure it. Read the selected candidate pair once connectionState is connected, and again after any ICE restart. In the W3C statistics spec, the transport object’s selectedCandidatePairId leads to a candidate-pair and its local and remote candidates (§8.18), each with a candidateType. Local relay candidates add relayProtocol, “the protocol used by the endpoint to communicate with the TURN server”. Firefox reports selectedCandidatePairId from version 153 (July 2026); older versions flag the pair with a non-standard selected. It returns one entry per transport (usually one); tested in Chrome 156 only. relayProtocol covers your side; the far end reports its own.
async function relayInfo(pc) {
const stats = await pc.getStats();
const pairs = [];
for (const r of stats.values()) {
if (r.type === 'transport' && r.selectedCandidatePairId) {
pairs.push(stats.get(r.selectedCandidatePairId));
}
}
// Fallback for Firefox before 153: non-standard `selected` on the pair
if (!pairs.length) {
for (const r of stats.values()) {
if (r.type === 'candidate-pair' && r.selected) pairs.push(r);
}
}
const sides = pairs.filter(Boolean).map((p) => {
const local = stats.get(p.localCandidateId);
const remote = stats.get(p.remoteCandidateId);
return {
localRelay: local?.candidateType === 'relay',
remoteRelay: remote?.candidateType === 'relay',
relayProtocol: local?.relayProtocol, // our side only, if relayed
};
});
return sides.length ? sides : null; // null: nothing selected yet
}
Log it with customer, region and app version, and track per segment:
- Relay share: sessions with a relay on either side, each counted once, ÷ sessions that connected. Keep the sample from after any ICE restart, and leave forced-relay test calls out.
- Protocol mix: a rising TLS share may indicate more users on networks that block UDP. It is an indicator, not proof.
- Connection failure rate: calls whose
connectionStatenever reachedconnected, split by gathering, connectivity-check and signaling outcome. Not every failure is TURN, but a share computed only over successful calls hides the ones that needed a relay.
What breaks in production, by symptom?
Confirm before you change anything.

| Symptom | Likely cause | How to confirm | Fix |
|---|---|---|---|
| Fails for some customers, fine on your network | No TURN, STUN-only iceServers, or a broken TURN config |
No relay candidates anywhere; test in our Trickle ICE tester |
Add TURN, or fix its URLs and credentials |
| Fails only on corporate, hospital or guest networks | UDP blocked; TURN on UDP only | Host candidates only; 701 (server unreachable) on the UDP TURN URL only; TCP and TLS URLs work in the tester. 701 can also mean DNS or routing | Add TURN over TCP, and TLS on 443 |
| No relay candidates; TURN authentication keeps failing | Invalid, expired or wrongly generated credentials; with time-limited ones, clock skew between issuer and TURN server | TURN log: a 401 after the client sent credentials (the first 401 is the normal challenge); expiry vs server clock | Fix credential generation; sync clocks |
| Relay candidates appear, relayed calls never connect | coturn behind NAT without external-ip |
The relay candidate carries a private address |
Set external-ip (public/private mapping); forward the relay port range through the NAT |
| Relay pair checks fail | Relay port range closed at a firewall or security group (coturn default 49152–65535) | TURN log shows the allocation; nothing reaches relay ports | Open your min-port–max-port range, inbound and outbound |
| Relayed calls connect but lag | Relay far from users | currentRoundTripTime (ICE-check RTT) on relay vs direct pairs, with loss and the relay’s region |
Relays per region |
| Drops when a user changes network | No ICE restart | ICE disconnected → failed after a Wi-Fi/cellular switch |
Restart ICE over signaling |
| Many relayed calls degrade at peak | Relay saturated | Egress near port capacity; loss and RTT rise on relay pairs only | Add nodes |
Several rows matching your tickets? Our WebRTC rescue team offers a free 30-minute call to find the failing layer.
The network-change row has a protocol reason: per RFC 8656 §3.2, client and server “remember the 5-tuple used in the Allocate request”, so a network change can invalidate the allocation. Your application should detect it and start an ICE restart for a new allocation and candidate pair. The restart travels over signaling, so design both recoveries together. And if a SIP gateway is in the path, FreeSWITCH is not a TURN relay: TURN belongs on the browser side.
How do you size a coturn server?
The honest finding first: we found no published sessions-per-core figure for coturn with a method. The README claims it “can handle thousands simultaneous calls per CPU (when TURN protocol is used)”, with no hardware, bitrate or test; the performance wiki has no benchmarks and calls itself outdated (December 2020). Size from your own traffic, in this order.
1. Bandwidth. Count ingress and egress separately, and count both sides of the relay. For a relayed participant whose far end (a peer or your SFU) isn’t on the same relay, there are four legs:
- in from the participant (their send), out to the far end (their send again);
- in from the far end (their receive), out to the participant (their receive again).
So egress ≈ send + receive, and ingress the same. Mapping send only to ingress and receive only to egress misses the far-end legs. In our test (Chrome 156 and a test TURN server, not coturn, one side relayed), a two-way call carrying 0.70 + 0.67 Mbps of media put 1.41 Mbps out of the relay and 1.45 Mbps in.
Peak relay egress ≈ peak concurrent relayed participants × (receive + send bitrate) × headroom
If both ends of a call relay through the same server, the leg between the two allocations stays on that server, so count only each relayed participant’s receive bitrate (our judgment; that case didn’t run in our test). As arithmetic, with assumptions to replace: 300 concurrent relayed participants, far ends off the relay, × (1 + 1 Mbps) = 600 Mbps; with 1.5× headroom, 900 Mbps egress and as much ingress. That is most of a 1 Gbit port, so plan two or more nodes. Through an SFU, “receive” is every subscribed stream, which can be several times the send rate.
2. Packets and file descriptors. Packets per second and per-packet CPU can run out before megabits. The 2020 wiki suggests raising the file-descriptor limit, RSS or RPS on the NIC, and one -m 0 instance per CPU core with its own address and relay port range. Re-test that on current coturn.
3. Failure domains. Two or more nodes in different zones, and relays in each region with users.
4. Your ceiling. coturn ships turnutils_uclient, “designed to simulate multiple clients”, with a load-generator mode. Run it from separate machines against one node, raise concurrency until loss appears, and record which resource ran out first. coturn’s max-bps and bps-capacity cap bandwidth per session and per server, in bytes per second, not bits.
Load balancing. The coturn README lists DNS SRV, a network load balancer and the “built-in 300 ALTERNATE-SERVER mechanism (requires 300 response support by the TURN client)”. The wiki’s note that WebRTC clients can’t use ALTERNATE-SERVER is superseded: RFC 8835 §3.4 says it “MUST be supported”, Chrome’s libwebrtc (turn_port.cc) handles it, and Firefox added it in version 90. We didn’t check Safari or native SDKs.
What does a TURN server actually cost?
Cost = GB relayed × price per GB, plus redundancy and the people who run it. Relayed participant-hours = all participant-hours × your relay share. At 1 Mbps each way, a relayed participant-hour moves 0.45 GB in each direction (3,600 megabits). Cloudflare meters 0.45 GB of that, Twilio 0.9 GB. A self-hosted relay sends 0.9 GB of egress when the far end is a peer or SFU off the relay, or 0.45 GB when both ends relay through it.

Public rates, read 19 November 2026; re-check them when you budget:
| Option | Listed rate | What is metered |
|---|---|---|
| Cloudflare Realtime TURN | $0.05 per GB; the first 1,000 GB each month are free, shared with Cloudflare’s SFU; TURN–SFU traffic is “not charged twice” | Data “sent from the Cloudflare edge to the TURN client”, overhead included; relay-to-peer leg “not part of billing” (TURN FAQ) |
| Twilio Network Traversal | Listed per GB: $0.40 US (Northern California) and Germany; $0.60 Singapore, Mumbai, Tokyo; $0.80 Sydney, São Paulo; STUN free | “the sum of bytes that the TURN Client sent and received” (FAQ) |
| Self-hosted, Hetzner dedicated root server | 1 Gbit uplink: unlimited traffic; 10 Gbit: 20 TB a month included, then €1 per TB ($1.20 as listed on 19 Nov 2026) | Outgoing traffic only |
| Self-hosted, AWS EC2 | 100 GB a month free data transfer out; tiered beyond | Tier prices aren’t on that page; use the AWS Pricing Calculator |
An illustrative estimate, not a vendor quote. Assume 10,000 relayed participant-hours a month at 1 Mbps each way. That averages about 14 concurrent relayed participants over a 30-day month (10,000 ÷ 720 hours), a scale where managed TURN usually wins on effort. Size servers on peak, not average.
- Cloudflare (standalone TURN): 4,500 GB × $0.05 = $225 a month, before the free allowance.
- Twilio: 9,000 GB × $0.40 = $3,600 in the US or Germany; $7,200 at $0.80.
- Self-hosted: 4.5 to 9 TB of egress (9 TB if the far ends are off the relay), inside a Hetzner 10 Gbit server’s 20 TB or unlimited on 1 Gbit, plus the servers. On AWS, put your egress figure into the calculator.
Self-hosting turns a per-GB bill into a fixed monthly cost, so the crossover is your fixed monthly cost ÷ the managed per-GB rate, in GB as that vendor meters them. If both participants relay, each is a TURN client, so expect each to be metered; confirm with the vendor.
Rates leave out a second region, standby nodes, monitoring, patching and on-call. For TURN next to SFU, recording and egress, see our breakdown of WebRTC costs in 2026.
If rules on where media may travel point you to self-hosting, designing and deploying that relay is work our WebRTC development team does.
Managed TURN, self-hosted coturn, or the relay built into your SFU?
| Managed TURN | Self-hosted coturn | TURN built into the SFU | |
|---|---|---|---|
| Fits when | You want relays in many regions without running them | Rules on where media may travel; high, steady relayed volume | Most calls already go through your SFU |
| You own | Credential issuance | Uptime, patching, security, regions, certificates | The SFU’s TURN domain, certificate and ports |
| Watch | A bill that grows with traffic; metering rules (above); media on the vendor’s network; which transports and ports it offers | Every item in the next section | Peer-to-peer calls outside the SFU still need TURN |
Check each SFU’s own docs. LiveKit “includes an embedded TURN server”; without a load balancer “turn.tls_port needs to be set to 443″.
How do you secure and monitor a TURN server?
A TURN server forwards packets to any address it may reach, so unrestricted, it is a way into your network. RFC 8656 §21.1.4 notes that “the server administrator may configure the server to restrict the range of IP addresses and ports”.
In 2020 Enable Security reported that through Slack’s TURN servers they could “Connect to the AWS meta-data services at http://169.254.169.254 and obtain IAM temporary credentials”, for a $3,500 bounty. Their CVE-2020-26262 bypassed coturn’s loopback protection with 0.0.0.0 (fixed in 4.5.2). Old research; the threat model still holds.
What defeats a relay, and what closes it:
- Relaying into internal ranges:
denied-peer-ipfor IPv4 and IPv6 private, loopback, link-local (169.254.169.254 included) and other special-purpose ranges, plusno-multicast-peers. Test the rules (Enable Security found that denying[::]seemed to block everything). - Leaked or long-lived credentials: coturn’s TURN REST API mode (
use-auth-secretwithstatic-auth-secret) gives time-limited credentials your backend issues per session, signed with the same secret. Set expiry to cover the session and reconnects; one credential can serve several allocations. - A flat network: “deploy your TURN servers on an isolated environment”, in Enable Security’s words.
- An old version: the latest coturn release on 19 November 2026 was 4.19.2 (18 November 2026). Patch it like any internet-facing service.
- Unused TCP relaying: coturn enables RFC 6062 TCP relay endpoints (relay to peer) by default, which browser-based WebRTC calls generally don’t use.
no-tcp-relayturns them off without touching TURN over TCP or TLS between the browser and the server, the fallback you need.
Monitor both ends. Server: active allocations, bytes in and out per node, allocation and refresh failures (allocations expire unless refreshed; RFC 8656’s default lifetime is 10 minutes), and authentication failures (a 401 after the client sent credentials, not the routine first challenge). Clients: relay share, protocol mix and connection failure rate per network. Alert on change: authentication-failure jumps point at credentials or clocks; a TLS-share jump may mean a network started blocking UDP.
How do you test that the relay works before users find out?
- Force the relay with
iceTransportPolicy: "relay". In the W3C WebRTC spec, the ICE agent then “uses only media relay candidates”. - Test each transport alone (UDP, TCP, TLS) in the Trickle ICE tester. A
relaycandidate proves the allocation, not media flow; the forced-relay call in step 1 proves media. - Test from hostile networks: a corporate proxy, a mobile carrier, hotel Wi-Fi, and a hospital network if you sell to clinics.
- Run a canary: a scheduled relay-only call per region and transport that alerts on failure, catching expired certificates and closed ports before customers do.
Our five-layer diagnosis puts TURN at layer 2.
What does this look like in a rescue?
On a vendor platform the relay can come included. For DateNight, a geosocial video-dating platform with thousands of concurrent private rooms, TokBox (Vonage) supplied the media layer, including TURN relay fallback.
One inherited failure shows how the table’s rows stack. On a telehealth platform, where a call that fails from a clinic is a visit that doesn’t happen, calls dropped or never connected, worse from clinics than from home. Two rows were live at once: clinic networks blocked UDP while the only TURN server, in one region, ran UDP alone with no TLS on 443; and under load that single relay saturated. The fix:
- multiple TURN servers across regions, on UDP, TCP and TLS 443
- short-lived per-session (HMAC) credentials
- monitoring on relay allocations and bandwidth
What we check first on an inherited stack: the iceServers the client actually receives, TCP and TLS 443 listeners, credential issuance and expiry, the relay port range in every firewall on the path, and relay share from real sessions. That is where a WebRTC rescue assessment begins.
Frequently asked questions
Do I still need TURN if I use an SFU? Usually. RFC 8835 notes that ICE-TCP “may allow applications to communicate to peers with public IP addresses across UDP-blocking firewalls without using a TURN server”, so an SFU on a public address that accepts ICE-TCP covers part of the gap, where clients support it. Networks that allow only TLS on 443 still need TURN over TLS. LiveKit embeds TURN; Jitsi’s handbook has you run one.
Can I use a free public STUN server in production? STUN relays nothing, and a public server is a dependency you don’t control. On TURN, Tsahi Levent-Levi is blunt: “Don’t use free public WebRTC turn servers.”
Can a TURN server see my call? Not the media. RFC 8827 §6.5: “All media channels MUST be secured via SRTP”, keyed by DTLS-SRTP between the endpoints, so the relay forwards encrypted packets. It still sees addresses, timing and volume. An SFU terminates DTLS-SRTP, so it can access media unless you add end-to-end encryption.
How many users can one coturn server handle?
No honest universal number exists. Size on bandwidth with the formula above, then measure with turnutils_uclient.
TURN over UDP, TCP or TLS on 443: which and when?
Offer all three and let ICE find the pair that works. The Jitsi handbook‘s default uses “UDP 3478 and TCP(TLS) on 5349” and notes “certain corporate networks which allow only TCP connections using port 443(https)”, so add a turns: listener on 443. TURN over TLS isn’t HTTPS, so some networks still block it. TCP and TLS are fallbacks, not equivalents of UDP: on a reliable, ordered transport, one lost packet holds back the ones behind it (head-of-line blocking), so loss turns into delay.
Calls failing on some networks? Book a free 30-minute technical call with our WebRTC rescue team. Bring your iceServers config (credentials removed) and a getStats() export from a failing session, and you’ll leave with an initial assessment of which layer is causing the issue. No deck, no pitch.