{"id":1062,"date":"2026-05-21T09:47:47","date_gmt":"2026-05-21T02:47:47","guid":{"rendered":"https:\/\/liveapi.com\/blog\/stun-server\/"},"modified":"2026-05-21T09:48:17","modified_gmt":"2026-05-21T02:48:17","slug":"stun-server","status":"publish","type":"post","link":"https:\/\/liveapi.com\/blog\/stun-server\/","title":{"rendered":"What Is a STUN Server? How It Works, Setup, and Use Cases"},"content":{"rendered":"<span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">11<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span><p>If you&#8217;ve built a video calling feature or any WebRTC integration, you&#8217;ve probably hit the same wall every other developer hits: two browsers behind home routers refuse to talk to each other directly. Network Address Translation (NAT) hides their real addresses behind a single public IP. Without a way to learn that public address, peer-to-peer media just doesn&#8217;t connect.<\/p>\n<p>A <strong>STUN server<\/strong> is the small but critical piece of infrastructure that solves this problem. It&#8217;s the first stop in almost every WebRTC call, every VoIP session, and many online game lobbies. This guide breaks down what a STUN server is, how the protocol works, which NAT types it handles, the public STUN servers you can use today, and how to deploy your own with open-source tools.<\/p>\n<h2>What Is a STUN Server?<\/h2>\n<p>A <strong>STUN server<\/strong> (Session Traversal Utilities for NAT) is a lightweight server that helps a client behind a NAT or firewall learn its public IP address and the port mapping used by its router. With that information, two peers on different networks can attempt a direct connection without routing traffic through a relay.<\/p>\n<p>STUN is defined by <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc8489\" target=\"_blank\" rel=\"nofollow\">RFC 8489<\/a>, which obsoletes the older RFC 5389. The protocol is intentionally simple: a client sends a binding request, the server returns the client&#8217;s reflexive (public) address, and the client uses that address as a connection candidate.<\/p>\n<table>\n<thead>\n<tr>\n<th>Attribute<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Full name<\/td>\n<td>Session Traversal Utilities for NAT<\/td>\n<\/tr>\n<tr>\n<td>Defined by<\/td>\n<td>RFC 8489 (replaces RFC 5389 and RFC 3489)<\/td>\n<\/tr>\n<tr>\n<td>Default ports<\/td>\n<td>UDP\/TCP 3478, TLS 5349<\/td>\n<\/tr>\n<tr>\n<td>Protocol type<\/td>\n<td>Lightweight client-server, request\/response<\/td>\n<\/tr>\n<tr>\n<td>Primary use<\/td>\n<td>Public IP and port discovery for NAT traversal<\/td>\n<\/tr>\n<tr>\n<td>Common pairing<\/td>\n<td>TURN servers and the ICE framework<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If your application needs to set up a direct peer connection \u2014 a one-to-one video call, a game session, a screen-sharing channel \u2014 the STUN server is almost always the first step.<\/p>\n<h2>How Does a STUN Server Work?<\/h2>\n<p>The STUN exchange is short. Most clients complete it in a single round trip. The point of the exchange is to tell the client one thing: from the public internet, here is what your address looks like.<\/p>\n<p>Here is the step-by-step flow:<\/p>\n<ol>\n<li><strong>The client picks a STUN server.<\/strong> This is configured in the application (for example, in a WebRTC <code>RTCPeerConnection<\/code> config) or resolved through DNS SRV records such as <code>_stun._udp<\/code>.<\/li>\n<li><strong>The client sends a binding request.<\/strong> It transmits a small UDP packet to the STUN server on port 3478. The packet contains a transaction ID and no authentication.<\/li>\n<li><strong>The server reads the source address.<\/strong> When the packet leaves the client&#8217;s network, the NAT rewrites the source IP and port. The STUN server sees those rewritten values, not the private LAN address.<\/li>\n<li><strong>The server returns the mapped address.<\/strong> The binding response contains an <code>XOR-MAPPED-ADDRESS<\/code> attribute holding the public IP and port the server observed. XOR encoding prevents older Application Layer Gateways from mangling the value.<\/li>\n<li><strong>The client stores the reflexive candidate.<\/strong> That public address becomes one of several ICE candidates the client can offer to its peer through a <a href=\"https:\/\/liveapi.com\/blog\/webrtc-signaling-server\/\" target=\"_blank\">WebRTC signaling server<\/a>.<\/li>\n<li><strong>The peers attempt a direct connection.<\/strong> Once both sides exchange candidates, ICE pairs them, runs connectivity checks, and picks the best path. If the direct path works, the STUN server&#8217;s job is done.<\/li>\n<\/ol>\n<p>Here is a short JavaScript example showing how a browser uses a STUN server inside a WebRTC peer connection:<\/p>\n<pre><code class=\"language-javascript\">const pc = new RTCPeerConnection({\n  iceServers: [\n    { urls: 'stun:stun.l.google.com:19302' }\n  ]\n});\n\npc.onicecandidate = (event) =&gt; {\n  if (event.candidate) {\n    \/\/ Send candidate to the remote peer via your signaling channel\n    sendToPeer({ type: 'candidate', candidate: event.candidate });\n  }\n};<\/code><\/pre>\n<p>The first time you call <code>createOffer()<\/code> on this <code>pc<\/code> object, the browser fires STUN binding requests to <code>stun.l.google.com:19302<\/code>, then surfaces the resulting reflexive candidates through <code>onicecandidate<\/code>. No SDK, no relay, no media yet \u2014 just address discovery.<\/p>\n<h2>STUN vs TURN vs ICE: How They Work Together<\/h2>\n<p>People often confuse STUN, TURN, and ICE because they all show up in the same <code>iceServers<\/code> array. They are not interchangeable; they solve different parts of the same problem.<\/p>\n<table>\n<thead>\n<tr>\n<th>Component<\/th>\n<th>Role<\/th>\n<th>When It Runs<\/th>\n<th>Bandwidth Cost<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>STUN<\/strong><\/td>\n<td>Finds the public IP and port for a NATed client<\/td>\n<td>Before media starts<\/td>\n<td>Near zero \u2014 a few small packets<\/td>\n<\/tr>\n<tr>\n<td><strong>TURN<\/strong><\/td>\n<td>Relays media when direct paths fail<\/td>\n<td>During the call, as a fallback<\/td>\n<td>High \u2014 every byte of audio\/video flows through it<\/td>\n<\/tr>\n<tr>\n<td><strong>ICE<\/strong><\/td>\n<td>Framework that gathers candidates and picks a working path<\/td>\n<td>Throughout connection setup<\/td>\n<td>Negligible \u2014 coordination only<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A typical <a href=\"https:\/\/liveapi.com\/blog\/webrtc-live-streaming\/\" target=\"_blank\">WebRTC live streaming<\/a> session starts by asking a STUN server for the public address, then collects host candidates (LAN addresses), then optionally collects relay candidates from a TURN server. ICE pairs them, runs connectivity checks, and chooses the best route \u2014 usually direct, sometimes relayed. For a deeper look at how ICE fits into the bigger picture, see our guide to <a href=\"https:\/\/liveapi.com\/blog\/nat-traversal\/\" target=\"_blank\">NAT traversal<\/a>.<\/p>\n<p>The key insight: STUN is cheap to run, TURN is expensive. You always try STUN first. You only fall back to TURN when STUN-mapped candidates fail to connect.<\/p>\n<h2>NAT Types and STUN Compatibility<\/h2>\n<p>STUN works for most home and small-office networks, but it does not work everywhere. The success rate depends on the NAT type sitting between the client and the public internet.<\/p>\n<p>There are four classic NAT behaviors:<\/p>\n<h3>Full Cone NAT<\/h3>\n<p>Any external host can send packets to the mapped public address. Once the client has obtained its mapping through STUN, peers can reach it directly. <strong>STUN works.<\/strong><\/p>\n<h3>Restricted Cone NAT<\/h3>\n<p>External hosts can reach the mapped address, but only if the client has previously sent a packet to that host&#8217;s IP. STUN-mapped addresses still work, but the client must initiate first. <strong>STUN works.<\/strong><\/p>\n<h3>Port-Restricted Cone NAT<\/h3>\n<p>Like restricted cone, but the external host must also send from the exact port the client wrote to. Still solvable with hole punching. <strong>STUN works.<\/strong><\/p>\n<h3>Symmetric NAT<\/h3>\n<p>The NAT creates a different public mapping for every destination. The mapping STUN returns is valid only for traffic to the STUN server itself \u2014 not for traffic to the peer. <strong>STUN fails. You need TURN.<\/strong><\/p>\n<p>Symmetric NATs are common in cellular networks and many enterprise firewalls. Real-world WebRTC deployments report that 8-20% of calls require TURN fallback because of symmetric NAT or restrictive firewalls. That percentage matters when you are sizing TURN bandwidth budgets \u2014 TURN traffic isn&#8217;t free, and it dominates streaming costs once you scale.<\/p>\n<p>If you are building a service where reliability matters more than infrastructure cost, plan for TURN from day one. If you are running a controlled environment (corporate LAN, gaming arena, fixed-location kiosks), STUN alone may be enough.<\/p>\n<h2>Common Use Cases for STUN Servers<\/h2>\n<p>STUN underpins almost every real-time peer-to-peer protocol. Anywhere two clients need to find each other across the public internet, STUN is in the path.<\/p>\n<h3>WebRTC video and audio calls<\/h3>\n<p>Every browser-based video call uses STUN. Google Meet, Discord voice, Slack huddles, and most <a href=\"https:\/\/liveapi.com\/blog\/video-conferencing-api\/\" target=\"_blank\">video conferencing API<\/a> products configure at least one STUN server in their ICE servers list. Without it, the calling browser would only see its LAN address and peers across the internet would never connect.<\/p>\n<h3>VoIP and SIP signaling<\/h3>\n<p>SIP phones, softphones, and PBX systems behind NAT use STUN to learn their public address before registering with a SIP registrar. This is how a desk phone behind a small-office router can receive a call from anywhere on the public internet.<\/p>\n<h3>Online gaming<\/h3>\n<p>Multiplayer games that use peer-to-peer matchmaking \u2014 fighting games, racing games, party games \u2014 rely on STUN to let console-to-console connections form. Microsoft, Sony, and Nintendo all run STUN-like services for matchmaking.<\/p>\n<h3>Peer-to-peer file sharing<\/h3>\n<p>Applications using NAT hole punching for file transfer (older versions of Skype, BitTorrent peer exchange, IPFS) use STUN to find reflexive candidates before negotiating direct paths.<\/p>\n<h3>IoT and home device control<\/h3>\n<p>Smart home apps that connect to cameras and sensors behind a home router often use STUN to set up direct media streams instead of pushing every frame through a cloud relay.<\/p>\n<h3>Hybrid streaming architectures<\/h3>\n<p>Some streaming platforms use WebRTC for ingest (the broadcaster&#8217;s upload) and HLS for delivery (the viewers&#8217; download). The ingest leg uses STUN. The delivery leg uses CDN-distributed HLS. For more on these tradeoffs, compare <a href=\"https:\/\/liveapi.com\/blog\/webrtc-vs-hls\/\" target=\"_blank\">WebRTC vs HLS<\/a>.<\/p>\n<h2>Public STUN Servers You Can Use<\/h2>\n<p>You do not need to run your own STUN server to get started. Several large companies operate free, public STUN servers that anyone can use. They are widely deployed, well-maintained, and free to query at modest volumes.<\/p>\n<table>\n<thead>\n<tr>\n<th>Provider<\/th>\n<th>Server URL<\/th>\n<th>Port<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Google<\/td>\n<td>stun:stun.l.google.com<\/td>\n<td>19302<\/td>\n<\/tr>\n<tr>\n<td>Google<\/td>\n<td>stun:stun1.l.google.com<\/td>\n<td>19302<\/td>\n<\/tr>\n<tr>\n<td>Google<\/td>\n<td>stun:stun2.l.google.com<\/td>\n<td>19302<\/td>\n<\/tr>\n<tr>\n<td>Cloudflare<\/td>\n<td>stun:stun.cloudflare.com<\/td>\n<td>3478<\/td>\n<\/tr>\n<tr>\n<td>Mozilla<\/td>\n<td>stun:stun.services.mozilla.com<\/td>\n<td>3478<\/td>\n<\/tr>\n<tr>\n<td>OpenRelay (Metered)<\/td>\n<td>stun:openrelay.metered.ca<\/td>\n<td>80<\/td>\n<\/tr>\n<tr>\n<td>Stunprotocol.org<\/td>\n<td>stun:stun.stunprotocol.org<\/td>\n<td>3478<\/td>\n<\/tr>\n<tr>\n<td>Twilio<\/td>\n<td>stun:global.stun.twilio.com<\/td>\n<td>3478<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A practical pattern: list two or three STUN servers in your <code>iceServers<\/code> config so the client has fallbacks if one is slow or temporarily unreachable. Most browsers will use whichever returns the reflexive candidate first.<\/p>\n<p>Public STUN servers come with one important caveat: they have no service-level agreement. They can disappear, throttle requests, or change addresses without notice. For a production app handling thousands of concurrent users, you should either pay for a managed TURN\/STUN service or run your own.<\/p>\n<h2>How to Set Up Your Own STUN Server<\/h2>\n<p>If you want full control over latency, uptime, and logging, run your own STUN server. The reference open-source implementation is <strong>coturn<\/strong>, which provides both STUN and TURN functionality in one binary.<\/p>\n<p>Here is a minimal setup on Ubuntu:<\/p>\n<pre><code class=\"language-bash\"># Install coturn\nsudo apt update\nsudo apt install coturn\n\n# Enable the service\nsudo sed -i 's\/#TURNSERVER_ENABLED=1\/TURNSERVER_ENABLED=1\/' \/etc\/default\/coturn\n\n# Edit the config\nsudo nano \/etc\/turnserver.conf<\/code><\/pre>\n<p>A starter <code>turnserver.conf<\/code> for STUN-only use looks like this:<\/p>\n<pre><code>listening-port=3478\ntls-listening-port=5349\nfingerprint\nrealm=stun.yourdomain.com\nno-multicast-peers\nno-cli\nexternal-ip=YOUR.PUBLIC.IP.ADDRESS<\/code><\/pre>\n<p>Then start the service and verify it&#8217;s listening:<\/p>\n<pre><code class=\"language-bash\">sudo systemctl restart coturn\nsudo netstat -tulpn | grep 3478<\/code><\/pre>\n<p>You should see coturn listening on UDP and TCP port 3478. To test the server from another machine, install <code>turnutils_stunclient<\/code> (shipped with coturn):<\/p>\n<pre><code class=\"language-bash\">turnutils_stunclient -p 3478 stun.yourdomain.com<\/code><\/pre>\n<p>A correct response will print the client&#8217;s reflexive address. If you see a timeout, check that firewall rules allow inbound UDP\/TCP on 3478 and that the <code>external-ip<\/code> value matches the host&#8217;s public IP.<\/p>\n<p>For deployments behind a load balancer or in a Kubernetes cluster, you will need to expose the port directly (no L7 termination), pin the pod to a known public address, and configure liveness probes that send actual STUN binding requests rather than TCP health checks. STUN over TCP responds the same way as STUN over UDP, so a simple TCP probe can mislead you.<\/p>\n<p>A note on hosting choices: building and operating low-latency, globally distributed STUN\/TURN infrastructure is its own engineering project. If your priority is shipping the streaming app rather than the plumbing under it, hosted platforms can abstract all of this. The <a href=\"https:\/\/liveapi.com\/live-streaming-api\/\" target=\"_blank\">LiveAPI live streaming API<\/a> handles RTMP and SRT ingest, multi-CDN delivery through Akamai, Cloudflare, and Fastly, and the broader infrastructure stack so your team can focus on application code.<\/p>\n<h2>Security Considerations for STUN Servers<\/h2>\n<p>STUN itself is a simple protocol. It does not move user data \u2014 only address mapping information. But there are still security details worth getting right.<\/p>\n<h3>No authentication on classic STUN<\/h3>\n<p>Vanilla STUN binding requests are unauthenticated. Anyone can query a public STUN server and learn their own public address. This is by design. You don&#8217;t lose anything by exposing your reflexive address; it&#8217;s already visible to anyone you send a packet to.<\/p>\n<h3>TURN credentials, not STUN credentials<\/h3>\n<p>If you are running coturn for both STUN and TURN, the TURN side requires long-term or time-limited credentials. Most production deployments use a <a href=\"https:\/\/datatracker.ietf.org\/doc\/html\/draft-uberti-rtcweb-turn-rest-00\" target=\"_blank\" rel=\"nofollow\">REST API pattern documented by the IETF<\/a> to mint short-lived TURN credentials per call. STUN-only queries remain open.<\/p>\n<h3>DDoS exposure<\/h3>\n<p>Open STUN servers can be abused as amplification reflectors in some configurations. Restrict the server&#8217;s response sizes, rate-limit per source IP, and consider firewall rules that drop spoofed source addresses (BCP 38).<\/p>\n<h3>TLS for sensitive deployments<\/h3>\n<p>For environments where even the server-client relationship is sensitive, run STUN over TLS on port 5349. The address discovery still works the same way; only the transport is encrypted.<\/p>\n<h3>Logging and PII<\/h3>\n<p>A STUN server sees source IPs of every request. That data is personally identifiable. If you log it, treat it as user data \u2014 apply your retention policy and access controls accordingly.<\/p>\n<h2>STUN Server Limitations<\/h2>\n<p>STUN solves a narrow problem well. It is worth knowing what it does not do.<\/p>\n<ul>\n<li><strong>It does not work behind symmetric NAT.<\/strong> The mapping a STUN server returns is not the mapping the peer will see. Symmetric NATs are common on mobile carriers and large corporate networks. Plan for TURN fallback.<\/li>\n<li><strong>It does not move media.<\/strong> STUN only maps addresses. The actual video and audio travel over a separate RTP\/SRTP path that ICE negotiates.<\/li>\n<li><strong>It cannot bypass restrictive firewalls.<\/strong> If a firewall blocks all outbound UDP, STUN&#8217;s discovery may succeed but the peer connection still won&#8217;t form. WebRTC implementations handle this by tunneling through TURN over TCP on port 443.<\/li>\n<li><strong>It has no built-in identity.<\/strong> STUN does not tell you who the peer is. Identity and authorization happen at the application layer \u2014 typically through your signaling channel.<\/li>\n<li><strong>It does not solve carrier-grade NAT cleanly.<\/strong> When multiple NAT layers stack, the mapping STUN returns may still be a private address. The client treats this as &#8220;no useful candidate&#8221; and falls back to TURN.<\/li>\n<\/ul>\n<p>For very low-latency requirements where TURN fallback is unacceptable, look at architectural alternatives: the <a href=\"https:\/\/liveapi.com\/blog\/srt-protocol\/\" target=\"_blank\">SRT protocol<\/a> for managed point-to-point streams, <a href=\"https:\/\/liveapi.com\/blog\/ultra-low-latency-video-streaming\/\" target=\"_blank\">ultra low latency video streaming<\/a> over WebRTC SFU topologies, or hybrid CDN delivery. The right answer depends on whether you need peer-to-peer (use STUN and TURN) or broadcast distribution (use HLS and CDN).<\/p>\n<h2>When to Use STUN in Your Application<\/h2>\n<p>Most modern apps with real-time peer-to-peer features should include STUN configuration. The cost is near-zero \u2014 a few small packets per call \u2014 and the failure mode is graceful (ICE will fall back to other candidate types).<\/p>\n<p>Use STUN when:<\/p>\n<ul>\n<li>You are building a WebRTC product (calls, conferencing, watch parties, peer-to-peer games).<\/li>\n<li>Your media path is peer-to-peer or peer-to-SFU and you want to skip CDN cost.<\/li>\n<li>You need direct paths for latency-sensitive interactions (sub-200ms round trips).<\/li>\n<li>You are integrating SIP\/VoIP endpoints behind NAT routers.<\/li>\n<\/ul>\n<p>Reach for a managed video platform when:<\/p>\n<ul>\n<li>Your distribution is one-to-many (livestream, broadcast). CDN delivery beats peer-to-peer here.<\/li>\n<li>You don&#8217;t want to operate STUN and TURN infrastructure.<\/li>\n<li>You want a single API surface for ingest, encoding, and delivery \u2014 see how a <a href=\"https:\/\/liveapi.com\/blog\/video-sdk\/\" target=\"_blank\">video SDK<\/a> or <a href=\"https:\/\/liveapi.com\/blog\/live-streaming-sdk\/\" target=\"_blank\">live streaming SDK<\/a> bundles these capabilities.<\/li>\n<\/ul>\n<p>The two approaches are not mutually exclusive. Plenty of products use WebRTC (with STUN) for the broadcaster&#8217;s upload and HLS for viewer playback. The <a href=\"https:\/\/liveapi.com\/blog\/best-live-streaming-apis\/\" target=\"_blank\">best live streaming APIs<\/a> support both ingest models so you can mix protocols by use case.<\/p>\n<h2>STUN Server FAQ<\/h2>\n<h3>What is the default port for a STUN server?<\/h3>\n<p>A STUN server listens on <strong>port 3478<\/strong> for both UDP and TCP, and on <strong>port 5349<\/strong> for STUN over TLS. Google&#8217;s public STUN servers use port 19302, which is a non-standard override. When you configure a STUN URL in WebRTC, the port is part of the URL string: <code>stun:server.example.com:3478<\/code>.<\/p>\n<h3>Is a STUN server free?<\/h3>\n<p>Yes \u2014 STUN is an open IETF protocol, and several major providers (Google, Cloudflare, Mozilla) operate free public STUN servers. There is no per-query fee. The catch is that public servers have no SLA, so production apps with strict reliability requirements often run their own coturn instances or pay for managed TURN\/STUN.<\/p>\n<h3>What is the difference between a STUN server and a TURN server?<\/h3>\n<p>A STUN server only tells a client its public IP and port. A TURN server actually relays media between peers when a direct connection fails. STUN is cheap and stateless; TURN is bandwidth-heavy and stateful. Most WebRTC deployments configure both \u2014 STUN first, TURN as fallback. See our comparison of <a href=\"https:\/\/liveapi.com\/blog\/webrtc-vs-websocket\/\" target=\"_blank\">WebRTC vs WebSocket<\/a> for more on how real-time protocols fit together.<\/p>\n<h3>Does WebRTC require a STUN server?<\/h3>\n<p>WebRTC will technically work on a single LAN without STUN, because both peers can use host candidates. The moment one peer is behind a NAT and the other is on a different network, you need STUN (or TURN) to establish the connection. In practice, every production <a href=\"https:\/\/liveapi.com\/blog\/what-is-webrtc\/\" target=\"_blank\">WebRTC<\/a> app includes at least one STUN server in its ICE configuration.<\/p>\n<h3>Can I use Google&#8217;s STUN server in production?<\/h3>\n<p>Many apps do, and it works well for development and small-scale production. Google operates several public STUN servers (<code>stun.l.google.com:19302<\/code> through <code>stun4.l.google.com:19302<\/code>). The caveats: no SLA, no support, and your traffic depends on a third party&#8217;s free service. For mission-critical apps, mirror the configuration with your own coturn deployment or a paid provider.<\/p>\n<h3>How do I test if a STUN server is working?<\/h3>\n<p>Use <code>turnutils_stunclient<\/code>, shipped with coturn, or the online <code>trickle-ice<\/code> test page hosted by the WebRTC project. Both send a binding request and print the reflexive address. If you get back your public IP, the server is working. If you get a timeout, the firewall, the server, or both are blocking traffic on port 3478.<\/p>\n<h3>What is XOR-MAPPED-ADDRESS in STUN?<\/h3>\n<p>It&#8217;s the STUN attribute that carries the client&#8217;s public address in the binding response. The value is XORed with the magic cookie defined in the STUN spec, which prevents older NAT devices and Application Layer Gateways from rewriting the address as if it were a normal IP in the packet payload. Modern STUN libraries handle the XOR transparently.<\/p>\n<h3>Does a STUN server work with IPv6?<\/h3>\n<p>Yes. STUN is address-family-agnostic and works with both IPv4 and IPv6. The <a href=\"https:\/\/en.wikipedia.org\/wiki\/STUN\" target=\"_blank\" rel=\"nofollow\">STUN protocol reference on Wikipedia<\/a> documents dual-stack support, and most modern STUN implementations bind to both <code>::<\/code> and <code>0.0.0.0<\/code>. If your network is IPv6-only, you may not need a STUN server at all \u2014 public IPv6 addresses are end-to-end reachable without NAT.<\/p>\n<h3>How many STUN servers should I configure?<\/h3>\n<p>Two or three is the sweet spot. One is fine for development. More than four offers diminishing returns and slows down ICE gathering because the browser waits for responses from all of them. Order them by geographic proximity to your users when possible.<\/p>\n<h3>What ports does a STUN server use besides 3478?<\/h3>\n<p>The IANA-assigned ports are <strong>3478<\/strong> for STUN over UDP and TCP, and <strong>5349<\/strong> for STUN over TLS. Google&#8217;s servers run on the non-standard port 19302. Some providers offer alternate ports like 80 and 443 to traverse restrictive corporate firewalls \u2014 for example, OpenRelay exposes STUN on port 80.<\/p>\n<h2>Ship Streaming Faster with LiveAPI<\/h2>\n<p>Running a STUN server and the TURN infrastructure around it is one of many problems you face when you build live video features from scratch. Ingest, transcoding, CDN delivery, player playback, recording, multistreaming \u2014 every piece needs operational attention. LiveAPI rolls those capabilities into a single API so your team can ship streaming apps in days instead of months. Pay-as-you-grow pricing, support for <a href=\"https:\/\/liveapi.com\/blog\/what-is-rtmp\/\" target=\"_blank\">RTMP<\/a> and SRT ingest, multi-CDN delivery, and an <a href=\"https:\/\/liveapi.com\/features\/\" target=\"_blank\">embeddable player and full feature set<\/a> come standard. <a href=\"https:\/\/liveapi.com\/\" target=\"_blank\">Get started with LiveAPI<\/a> and turn your video roadmap into shipping product.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\">11<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span> If you&#8217;ve built a video calling feature or any WebRTC integration, you&#8217;ve probably hit the same wall every other developer hits: two browsers behind home routers refuse to talk to each other directly. Network Address Translation (NAT) hides their real addresses behind a single public IP. Without a way to learn that public address, peer-to-peer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1063,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_title":"What Is a STUN Server? How It Works and How to Set One Up %%sep%% %%sitename%%","_yoast_wpseo_metadesc":"Learn what a STUN server is, how STUN works for NAT traversal, public STUN server lists, setup with coturn, and how it powers WebRTC and VoIP apps.","inline_featured_image":false,"footnotes":""},"categories":[31],"tags":[],"class_list":["post-1062","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-webrtc"],"jetpack_featured_media_url":"https:\/\/liveapi.com\/blog\/wp-content\/uploads\/2026\/05\/stun-server.jpg","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.6.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"description\" content=\"Learn what a STUN server is, how STUN works for NAT traversal, public STUN server lists, setup with coturn, and how it powers WebRTC and VoIP apps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/liveapi.com\/blog\/stun-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Is a STUN Server? How It Works and How to Set One Up - LiveAPI Blog\" \/>\n<meta property=\"og:description\" content=\"Learn what a STUN server is, how STUN works for NAT traversal, public STUN server lists, setup with coturn, and how it powers WebRTC and VoIP apps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/liveapi.com\/blog\/stun-server\/\" \/>\n<meta property=\"og:site_name\" content=\"LiveAPI Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-21T02:47:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-21T02:48:17+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"16 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/liveapi.com\/blog\/#website\",\"url\":\"https:\/\/liveapi.com\/blog\/\",\"name\":\"LiveAPI Blog\",\"description\":\"Live Video Streaming API Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/liveapi.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/liveapi.com\/blog\/stun-server\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/liveapi.com\/blog\/wp-content\/uploads\/2026\/05\/stun-server.jpg\",\"width\":1880,\"height\":1251,\"caption\":\"Photo by Brett Sayles on Pexels\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/liveapi.com\/blog\/stun-server\/#webpage\",\"url\":\"https:\/\/liveapi.com\/blog\/stun-server\/\",\"name\":\"What Is a STUN Server? How It Works and How to Set One Up - LiveAPI Blog\",\"isPartOf\":{\"@id\":\"https:\/\/liveapi.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/liveapi.com\/blog\/stun-server\/#primaryimage\"},\"datePublished\":\"2026-05-21T02:47:47+00:00\",\"dateModified\":\"2026-05-21T02:48:17+00:00\",\"author\":{\"@id\":\"https:\/\/liveapi.com\/blog\/#\/schema\/person\/98f2ee8b3a0bd93351c0d9e8ce490e4a\"},\"description\":\"Learn what a STUN server is, how STUN works for NAT traversal, public STUN server lists, setup with coturn, and how it powers WebRTC and VoIP apps.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/liveapi.com\/blog\/stun-server\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/liveapi.com\/blog\/#\/schema\/person\/98f2ee8b3a0bd93351c0d9e8ce490e4a\",\"name\":\"govz\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/liveapi.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ab5cbe0543c0a44dc944c720159323bd001fc39a8ba5b1f137cd22e7578e84c9?s=96&d=mm&r=g\",\"caption\":\"govz\"},\"sameAs\":[\"https:\/\/liveapi.com\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/posts\/1062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/comments?post=1062"}],"version-history":[{"count":1,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/posts\/1062\/revisions"}],"predecessor-version":[{"id":1064,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/posts\/1062\/revisions\/1064"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/media\/1063"}],"wp:attachment":[{"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/media?parent=1062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/categories?post=1062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/liveapi.com\/blog\/wp-json\/wp\/v2\/tags?post=1062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}