A STUN server is a host on the public internet that answers a STUN Binding request by telling the client which public IP address and port the request arrived from, on port 3478 over UDP or TCP by default and 5349 over TLS or DTLS (RFC 8489, 2020). WebRTC and SIP clients use that address as a server-reflexive candidate to reach a peer directly; when no direct path works, a TURN server relays the media. On 15 November 2026 we probed all 269 entries of the GitHub list that Google ranked first for this query: 79 answered, 93 hostnames no longer resolve, and 29 responders still use the 2003 reply format.

How the STUN protocol works: a 20-byte request and a reply with your address

STUN discovery is one request and one response. Each NAT on the way rewrites the request's source address and port, and the server copies the source address it sees, the "reflexive transport address" (RFC 8489 §2), into the response. A Binding request without attributes is only the header:

Header field (RFC 8489 §5)SizeValue in a Binding requestPurpose
Message type2 bytes0x0001 (success response: 0x0101)Method and class; the top 2 bits are always zero
Message length2 bytes0Bytes after the 20-byte header
Magic cookie4 bytes0x2112A442Marks a post-RFC 3489 client; separates STUN from other packets on one port
Transaction ID12 bytesRandom"MUST be cryptographically random"; echoed so the client can match the response

The success response carries the address in XOR-MAPPED-ADDRESS (attribute 0x0020): the port XORed with the top 16 bits of the magic cookie, an IPv4 address with the whole cookie, an IPv6 address with the cookie plus the transaction ID (§14.2). The XOR exists because "some NATs rewrite the 32-bit binary payloads containing the NAT's public IP address", which broke RFC 3489's plain MAPPED-ADDRESS. SIP-aware ALGs cause their own failures on VoIP paths; see VoIP monitoring.

Over UDP the client retransmits: the first timeout "SHOULD be greater than or equal to 500 ms" and doubles, up to 7 requests, so with a 500 ms start a client treats an unreachable server as failed after 39.5 seconds (§6.2.1).

What a STUN server does not do

A STUN server reports an address and nothing else. Four jobs attributed to it belong elsewhere:

  • Relaying media. Media goes peer to peer, or through a TURN relay (RFC 8656).
  • Signalling. ICE agents send candidates to each other "over the signaling channel" (RFC 8445 §2.2): your WebSocket, SIP or HTTP exchange.
  • Opening ports. The client's own outgoing packet creates the NAT binding; STUN reports it and can keep it alive (RFC 8489 §1). Whether a peer may send to it is up to the NAT.
  • NAT traversal on its own. "A basic STUN server is not a solution for NAT traversal by itself" (RFC 8489 §12).

STUN vs TURN vs ICE: which one carries media, needs credentials, costs bandwidth

STUNTURNICE
What it isServer that reports your reflexive addressSTUN extension: server allocates a relayed address and forwards packetsProcedure in each endpoint: gather candidates, exchange them, test pairs
Media through itNoYes, on a relayed pathNo
CostCloudflare and Twilio price STUN at zero"a high cost to the provider" because of bandwidth (RFC 8656 §1); Twilio bills relayed dataRuns in the clients
CredentialsBasic server "SHOULD NOT" use any (RFC 8489 §12)Long-term credentials MUST be implemented (RFC 8656 §5); browsers reject turn: URLs without username and credentialShort-term credentials from the peers' ICE username fragments and passwords (RFC 8445 §7.2.2)
Default ports3478 UDP/TCP, 5349 TLS/DTLSSame: 3478, 5349Uses the candidates' ports
Candidate typesrflxrelay (and srflx)Finds prflx during checks
SpecificationRFC 8489 (2020), after RFC 5389 (2008) and RFC 3489 (2003, "classic STUN")RFC 8656 (2020), after RFC 5766RFC 8445 (2018); Trickle ICE RFC 8838 (2021)

When STUN is not enough: NAT mapping behaviour, blocked UDP, and what a TURN server does

An address learned from a STUN server helps a peer only if the NAT reuses the same public mapping for every destination. RFC 4787 (BCP 127, 2007) §4.1 defines three mapping behaviours:

Mapping behaviourMapping reused for packets toDoes a peer see the STUN-learned address?
Endpoint-independentAny external address and portYes
Address-dependentThe same external IP addressNo, a new mapping per peer address
Address and port-dependentThe same external IP address and portNo

RFC 4787 REQ-1 says "A NAT MUST have an 'Endpoint-Independent Mapping' behavior", because "failure to meet REQ-1 will force the use of a UDP relay". RFC 3489 called such NATs "symmetric", a term RFC 4787 dropped as "inadequate at describing real-life NAT behavior". When both hosts sit behind address-dependent or address-and-port-dependent mapping, "hole punching techniques generally fail" (RFC 8656 §1). The same section notes: "In many enterprise networks, direct UDP transmissions are not permitted between clients on the internal networks and external IP addresses."

A TURN server covers both cases: after an Allocate request with long-term credentials it reserves a relayed transport address, peers send to it, and the server forwards traffic both ways; in WebRTC that address is a relay candidate. RFC 8656 advises using TURN "only when a direct communication path cannot be found". What fails on a TURN server and how to probe allocations is in TURN server monitoring.

Where ICE candidates and Trickle ICE fit

An ICE candidate is one transport address at which a peer might be reached. The W3C WebRTC API reports its type in RTCIceCandidate.type:

typeAddress comes fromType preference (RFC 8445 §5.1.2.2)
hostA local interface126
prflxConnectivity checks with the peer110
srflxA STUN Binding response100
relayA TURN allocation0

ICE checks each local/remote pair with a STUN Binding request sent straight to the peer, and RFC 8445 §7.2.4 is explicit about those checks: "Support for backwards compatibility with RFC 3489 MUST NOT be assumed". Trickle ICE (RFC 8838) sends candidates as they are found, so checks start before gathering ends. In a browser each candidate arrives as an icecandidate event; a null candidate marks the end.

Google STUN server and other public STUN servers: what answered on 15 November 2026

We sent RFC 8489 Binding requests over UDP/IPv4 from one host in Western Europe, 5 per server with a 2-second timeout, and took the median round-trip time; every server below answered all 5. The times describe that host at that moment, not your latency: the five Google hostnames resolved to the same address, and their medians still ranged from 13.0 to 35.3 ms.

ServerMedian RTT from our hostAddress attributesSOFTWARE
stun.l.google.com:1930213.1 msXOR-MAPPEDnone
stun1–stun4.l.google.com:1930213.0–35.3 msXOR-MAPPEDnone
stun.l.google.com:347814.3 msXOR-MAPPEDnone
stun.cloudflare.com:3478 / :535.1 / 5.2 msXOR-MAPPEDnone
global.stun.twilio.com:347867.1 msXOR-MAPPED, MAPPEDnone
stun.nextcloud.com:443 / :3478 *85.0 / 83.0 msXOR-MAPPED, MAPPEDnone
stunserver2025.stunprotocol.org:3478 *136.7 msXOR-MAPPED, MAPPEDnone
stun.telnyx.com:347861.9 msXOR-MAPPED, MAPPEDnone
stun.signalwire.com:3478 *138.6 msXOR-MAPPED, MAPPEDthe string "None"
stun.freeswitch.org:3478 *102.3 msXOR-MAPPED, MAPPEDthe string "None"
stun.sipgate.net:3478 / :10000 *39.5 / 40.9 msXOR-MAPPED, MAPPEDCoturn-4.5.2 'dan Eider'
stun.linphone.org:347834.5 msXOR-MAPPED, MAPPED, SOURCE-ADDRESS, CHANGED-ADDRESSoRTP 0.99
stun.relay.metered.ca:8054.6 msXOR-MAPPEDnone
stun.framasoft.org:347835.4 msXOR-MAPPEDnone
stun.t-online.de:347875.1 msMAPPED, SOURCE-ADDRESS, CHANGED-ADDRESS; no XOR-MAPPEDnone

* Also returned OTHER-ADDRESS, the RFC 5780 attribute that NAT behaviour tests such as coturn's turnutils_natdiscovery need. All five Google hostnames resolved to one IPv4 address from our host in both runs.

A server that answers is not a server you may use. What operators document:

OperatorOwn documentation
GoogleThe example iceServers entry on webrtc.org and the default on the Trickle ICE sample page. Google Workspace lists it "(used for STUN requests)" among hosts its Voice product must reach. We found no Google page offering it to third parties with terms.
Cloudflare"Cloudflare's STUN service at stun.cloudflare.com is free and unlimited" (Realtime FAQ). Documented port: UDP 3478. Port 53 answered us, but Cloudflare's credentials page says of its port-53 URLs that "the alternate port 53 is known to be blocked by web browsers".
TwilioThe Network Traversal Service token lists stun:global.stun.twilio.com:3478; the pricing page lists STUN as "Free".
stunprotocol.org"A STUN service hosting the Stuntman code is being run at stunserver2025.stunprotocol.org (UDP and TCP ports 3478)"; no terms stated.
Nextcloudstun.nextcloud.com:443 is DEFAULT_STUN_SERVER in Nextcloud Talk's source; the docs call it "preconfigured for Nextcloud Talk".

Only Cloudflare and Twilio state a price and scope for other people's applications. A default in someone's configuration, or a line in a gist, is not permission to use their server; we did not look up terms for the other rows.

How many servers in the GitHub STUN lists still answer?

The same day we probed every entry of two GitHub lists that Google returned on its first page for "what is a stun server" (US results, 15 November 2026; the mondain gist was first): 3 requests per server, 2-second timeout, servers probed concurrently.

ListEntriesAnsweredOf those, MAPPED-ADDRESS onlyDid not resolveNo answer
gist mondain/b0ec1cf5f60ae726202e26979299397
gist zziuni/3741933198265

The 79 responders in the larger list sit on 51 IPv4 addresses; 18 hostnames resolved to two adjacent addresses, all 18 MAPPED-ADDRESS only. Five of the eight responders in the smaller list are Google's. Well-known entries that did not answer us:

Hostname (port 3478)ListResult
stun.services.mozilla.commondainDoes not resolve
stun.stunprotocol.orgmondainDoes not resolve
stun.ideasip.combothDoes not resolve
stun.iptel.orgbothDoes not resolve
stun.ekiga.netbothNo answer
stun.voiparound.combothNo answer
stunserver.orgbothNo answer
stun.voxgratia.orgbothNo answer
stun.counterpath.commondainNo answer
stun.3cx.commondainNo answer

All ten failed the same way in our 5-request run too.

What the MAPPED-ADDRESS-only servers are doing

Our request carried the magic cookie, and RFC 8489 §6.3.1.1 says the server forming a Binding success response "adds an XOR-MAPPED-ADDRESS attribute". RFC 5389 §12.2 allows MAPPED-ADDRESS instead only when the server detects an RFC 3489 client "by the absence of the correct value in the magic cookie field". The 29 answer a current client as RFC 3489 servers did; the four of them in our 5-request run also returned SOURCE-ADDRESS and CHANGED-ADDRESS, which IANA lists as reserved since RFC 5389. RFC 8489 §6.3.3 has the client check "that the XOR-MAPPED-ADDRESS attribute is present"; under RFC 5389 §12, compatibility is optional: "A usage must define if and when this procedure is used." We did not test how browsers handle such responses.

How to test a STUN server yourself

A STUN server test is one Binding request plus a check that the reply belongs to it. This trimmed version of our probe (Python 3 standard library, UDP, IPv4) prints the round-trip time, the attribute returned and your public address:

#!/usr/bin/env python3
# One STUN Binding request over UDP/IPv4 (RFC 8489).
# Usage: python3 stun_check.py stun.l.google.com 19302
import os, socket, struct, sys, time

MAGIC = 0x2112A442

def binding(host, port=3478, timeout=2.0):
    ip = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_DGRAM)[0][4][0]
    tid = os.urandom(12)                                  # 96-bit transaction ID
    req = struct.pack("!HHI", 0x0001, 0, MAGIC) + tid     # Binding request, no attributes
    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
        s.settimeout(timeout)
        t0 = time.perf_counter()
        s.sendto(req, (ip, port))
        data, _ = s.recvfrom(2048)
        rtt_ms = (time.perf_counter() - t0) * 1000
    mtype, mlen = struct.unpack("!HH", data[:4])
    if mtype != 0x0101 or data[8:20] != tid:              # success response to OUR request?
        raise ValueError("not a Binding success response to this transaction")
    i, legacy = 20, None
    while i + 4 <= min(20 + mlen, len(data)):
        atype, alen = struct.unpack("!HH", data[i:i + 4])
        v = data[i + 4:i + 4 + alen]
        if atype == 0x0020 and alen >= 8 and v[1] == 0x01:  # XOR-MAPPED-ADDRESS, IPv4
            xport = struct.unpack("!H", v[2:4])[0] ^ (MAGIC >> 16)
            xaddr = struct.unpack("!I", v[4:8])[0] ^ MAGIC
            return rtt_ms, f"{socket.inet_ntoa(struct.pack('!I', xaddr))}:{xport}", "XOR-MAPPED-ADDRESS"
        if atype == 0x0001 and alen >= 8 and v[1] == 0x01:  # MAPPED-ADDRESS (RFC 3489 servers)
            legacy = f"{socket.inet_ntoa(v[4:8])}:{struct.unpack('!H', v[2:4])[0]}"
        i += 4 + alen + (-alen % 4)                       # attributes are padded to 4 bytes
    return rtt_ms, legacy, "MAPPED-ADDRESS only"

if __name__ == "__main__":
    host = sys.argv[1]
    port = int(sys.argv[2]) if len(sys.argv) > 2 else 3478
    try:
        rtt, addr, attr = binding(host, port)
        print(f"{host}:{port}  {rtt:.1f} ms  {attr}  {addr}")
    except socket.gaierror:
        print(f"{host}: does not resolve")
    except socket.timeout:
        print(f"{host}:{port}  no answer within 2 s")

It sends one request where RFC 8489 clients retransmit, so repeat it before calling a server unreachable. coturn's client takes an IP address:

turnutils_stunclient -p 19302 "$(dig +short A stun.l.google.com | tail -n 1)"
# -c  continuous Binding requests with round-trip latency; -t  timeout in ms (default 3000)

turnutils_stunclient sends an RFC 5389 request over UDP and "does not support the 'old' 'classic' STUN protocol (RFC 3489)". In a browser, the Trickle ICE sample page states its pass condition: "If you test a STUN server, it works if you can gather a candidate with type 'srflx'." If no host candidate can reach the server, the W3C spec has the browser fire icecandidateerror with errorCode 701. How this check fits the other layers of a call is in WebRTC testing.

How to configure STUN and TURN in RTCPeerConnection

A WebRTC STUN server goes into iceServers as a URL alone; a TURN entry needs username and credential. The transport's selectedCandidatePairId in getStats() shows which path a call uses:

const pc = new RTCPeerConnection({
  iceServers: [
    { urls: "stun:stun.cloudflare.com:3478" },          // STUN: no credentials
    { urls: ["turn:turn.example.com:3478?transport=udp",
             "turns:turn.example.com:5349?transport=tcp"],
      username: "from-your-credential-service",
      credential: "from-your-credential-service" }
  ]
  // iceTransportPolicy: "relay"   // relay candidates only: tests TURN alone
});

async function selectedPath(pc) {
  const stats = await pc.getStats();
  for (const s of stats.values()) {
    if (s.type === "transport" && s.selectedCandidatePairId) {
      const pair = stats.get(s.selectedCandidatePairId);
      const local = stats.get(pair.localCandidateId);
      return { local: local.candidateType,   // host | srflx | prflx | relay
               server: local.url,             // ICE server behind an srflx or relay candidate
               rttSeconds: pair.currentRoundTripTime };
    }
  }
  return null;
}

A local relay candidate on the selected pair means TURN carries the media; srflx or host means a direct path.

Running your own STUN server with coturn

coturn is "a free open source implementation of TURN and STUN Server": one turnserver process answers Binding requests and TURN allocations on 3478 (UDP, TCP) and 5349 (TLS, DTLS) by default. STUN options in coturn 4.19.0:

OptionEffect
-S, --stun-only"Run as STUN server only, all TURN requests will be ignored."
--no-stun"Run as TURN server only, all STUN requests will be ignored."
--secure-stunRequires authenticated Binding requests; the default is anonymous access
--stun-backward-compatibilityAdds MAPPED-ADDRESS next to XOR-MAPPED-ADDRESS: "Strongly encouraged to keep this option off to decrease gain factor in STUN binding responses"
--rfc5780Enables NAT behaviour discovery, off by default because the extra attributes "increase the possibility of an amplification attack"

A STUN-only instance ignores Allocate requests, so it opens no relay ports. TURN adds credentials, a relay port range and certificates; see what to check on a TURN server.

When the standard advice fails

"Add stun1 to stun4 for redundancy." From our host all five Google names resolved to one address. Configure STUN servers from two operators instead.

The STUN check passes while calls fail. A Binding request needs no credentials and no relay port, so it succeeds while TURN credentials are wrong or the relay range is firewalled, and behind address-dependent mapping the gathered srflx candidate is useless to the peer. Test TURN on its own with iceTransportPolicy: "relay".

IPv6. A dual-stack client "MUST query both" A and AAAA records (RFC 8489 §8.1), and the mapped address "will not necessarily match the address family of the server address used" (§12). An answer over IPv4 says nothing about the IPv6 path.

UDP blocked, TCP only. A Binding request over UDP gets no reply, so the STUN server yields no server-reflexive candidate (RFC 8445 defines ICE for UDP; TCP candidates are RFC 6544). What works there is TURN over TCP or TLS: turn: with ?transport=tcp, or turns: on 5349 or 443.

A manual test answers "does it work from here, now". Catching failures before users do takes scheduled probes from outside your network; RTCanary runs STUN binding, TURN allocation and relay round-trip checks from several regions, described in how it works.

Limitations of our probe

  • One host in Western Europe. A timeout can be specific to that path; "did not answer us" is not "down".
  • UDP over IPv4 only; no TCP, no TLS on 5349, no IPv6.
  • One day, two runs within minutes; results can differ later. The list run sent requests to many servers at once, so we report no round-trip times from it.
  • 3 or 5 requests and a 2-second timeout, far less than the 39.5 seconds an RFC 8489 client may wait.
  • One DNS resolver, first IPv4 address only; geographic DNS may send you elsewhere.

FAQ

What is STUN port 3478?

3478 is the default port for STUN over UDP and TCP; 5349 is the default over TLS and DTLS (RFC 8489 §8.1). TURN uses the same defaults (RFC 8656 §4.1). Servers can listen elsewhere: Google's sample configuration uses 19302.

What protocol does STUN use?

STUN is its own binary request/response protocol (RFC 8489), carried over UDP, TCP, TLS over TCP or DTLS over UDP. A basic STUN server "MUST support UDP and TCP" (§12).

What are the IP addresses of Google STUN servers?

We found no address list from Google, only hostnames: stun.l.google.com:19302 and stun1 to stun4. From our host all five resolved to one IPv4 address, an answer specific to the resolver and the moment, so configure the hostname.

What is a coturn server?

coturn is an open-source STUN and TURN server. One process answers both unless --stun-only or --no-stun is set; turnutils_stunclient is its test client.

Do I need a TURN server if I have a STUN server?

Yes, for users on networks that block UDP or behind address-dependent mapping on both ends (RFC 8656 §1). We know of no primary source measuring what share of calls that is.

Is there a free STUN server for production?

Cloudflare documents stun.cloudflare.com as "free and unlimited", and Twilio prices STUN at zero. Google's server answers, but we found no terms for third-party use. GitHub lists are no guide: 190 of 269 entries in the top-ranked one did not answer us.

Sources

  1. RFC 8489, Session Traversal Utilities for NAT (STUN), February 2020.
  2. RFC 5389, STUN, October 2008: §12.
  3. RFC 3489, STUN ("classic STUN"), March 2003.
  4. RFC 8656, Traversal Using Relays around NAT (TURN), February 2020.
  5. RFC 8445, Interactive Connectivity Establishment (ICE), July 2018.
  6. RFC 8838, Trickle ICE, January 2021.
  7. RFC 4787 (BCP 127), NAT Behavioral Requirements for Unicast UDP, January 2007.
  8. RFC 5780, NAT Behavior Discovery Using STUN, May 2010 (Experimental).
  9. IANA, STUN Attributes registry.
  10. W3C, WebRTC: Real-Time Communication in Browsers, Recommendation 13 March 2025.
  11. W3C, Identifiers for WebRTC's Statistics API, Candidate Recommendation Draft 25 September 2025.
  12. WebRTC samples, Trickle ICE; webrtc.org, Getting started with peer connections (updated 10 November 2025).
  13. Google Workspace, Voice connectivity requirements.
  14. Cloudflare Realtime TURN, FAQ, generate credentials.
  15. Twilio, Network Traversal Service; pricing.
  16. stunprotocol.org.
  17. Nextcloud Talk, lib/Config.php; Talk TURN documentation.
  18. coturn 4.19.0 README.turnserver, README.turnutils, README.md.
  19. gist mondain/b0ec1cf5f60ae726202e and gist zziuni/3741933: the lists we probed.