What is a TURN Server? A 2025 Guide to TURN Protocol, NAT Traversal, and Real-Time Communication

Learn what a TURN server is, why it's crucial for NAT traversal and real-time apps, and how to set one up. Includes protocols, security, and provider tips.

What is a TURN Server?

A TURN (Traversal Using Relays around NAT) server is a critical component in modern real-time communication systems, enabling seamless data exchange between clients even when they are behind strict NATs (Network Address Translators) or firewalls. TURN servers relay media and data traffic when direct peer-to-peer connections are not possible, ensuring reliable connectivity for applications like WebRTC video calls, VoIP, and online gaming. In a world where secure and uninterrupted real-time communication is essential, understanding TURN servers is vital for developers and network architects in 2025.

Understanding the TURN Server Protocol

The TURN protocol is defined by

RFC 8656

and is closely related to the STUN (Session Traversal Utilities for NAT) protocol. While STUN facilitates NAT traversal by discovering public IP addresses and ports, TURN takes over when direct peer-to-peer communication fails due to restrictive NATs or firewalls. TURN operates as a relay server, forwarding data between clients to guarantee connectivity.
TURN is a cornerstone of the ICE (Interactive Connectivity Establishment) protocol, which orchestrates the selection of the best communication path for real-time data. When STUN cannot establish a direct connection, the ICE protocol falls back to TURN. As a result, the TURN server becomes indispensable in scenarios where stringent network security policies or symmetric NATs are in place. In 2025, as network environments grow more complex, TURN's role in overcoming connectivity barriers is more crucial than ever.

Why Do We Need TURN Servers?

NATs and firewalls are designed to protect private networks by modifying or blocking inbound and outbound traffic. However, these security measures can impede peer-to-peer communication, making it challenging for clients to connect directly. This is especially problematic in real-time applications like video conferencing, file sharing, and online gaming, where low latency and uninterrupted streams are expected. For developers working with

webrtc android

or building cross-platform solutions such as

flutter webrtc

, TURN servers are essential to ensure consistent connectivity regardless of the user's network environment.
Let’s visualize the NAT traversal process with and without a TURN server:
  • Without TURN: If both clients are behind strict NAT/firewall, direct communication fails.
  • With TURN: The TURN server relays data, bridging the gap and ensuring the session succeeds.
In real-world scenarios, such as a WebRTC video call between two users on different networks, a TURN server is often the only way to bypass these barriers. Without TURN, many communications would fail due to symmetric NAT restrictions or enterprise-grade firewalls that block incoming connections. TURN servers thus guarantee reliability and compatibility across diverse network configurations. This reliability is crucial for applications built with a

javascript video and audio calling sdk

or when integrating a robust

Video Calling API

into your product.

How Does a TURN Server Work?

The TURN server operates by relaying data packets between clients that cannot connect directly. Here’s a step-by-step breakdown:
  1. Client Allocation: The client contacts the TURN server to request allocation of a relayed transport address.
  2. Relayed Transport Address: The TURN server assigns a public IP address and port (the relayed address) to the client.
  3. Data Flow: All media and data traffic are sent from the client to the TURN server, which then relays it to the target peer.
  4. Protocols Used: TURN supports UDP, TCP, and TLS transports, providing flexibility and security for various network environments.
For teams looking to

embed video calling sdk

into their web or mobile apps, understanding how TURN servers handle media relay is vital for delivering seamless user experiences.

Key Concepts

  • Allocation: The process where a client reserves resources on the TURN server for relaying traffic.
  • Relayed Transport Address: A public-facing IP and port provided by the TURN server, used by peers to send/receive data.

TURN Protocol Flow (Pseudo-Code Example)

1// WebRTC TURN server allocation (simplified)
2const turnConfig = {
3  iceServers: [
4    {
5      urls: ["turn:turn.example.com:3478"],
6      username: "user",
7      credential: "pass"
8    }
9  ]
10};
11
12const peerConnection = new RTCPeerConnection(turnConfig);
13
14// Add media tracks, create offer, etc.
15peerConnection.createOffer().then(offer => {
16  // Send offer to remote peer via signaling server
17});
18
This pseudo-code configures a WebRTC peer connection to use a TURN server, ensuring media flows even if direct connectivity is blocked. If you're developing cross-platform apps, you might also consider using a

react native video and audio calling sdk

to streamline integration across devices.

TURN Server vs STUN Server

STUN and TURN are both key to NAT traversal, but their roles differ:
FeatureSTUN ServerTURN Server
RoleDiscover public IP/portRelay media/data
Peer-to-peerYes (if possible)No (always relayed)
Use casesSimple NAT traversal, VoIPSymmetric NAT, firewalls
Bandwidth usageMinimalHigh (relays traffic)
CostLow (CPU/network)High (bandwidth/infra)
SecurityBasicSupports authentication
  • When to use STUN: Use STUN when clients are behind basic NATs and direct communication is feasible.
  • When to use TURN: Use TURN when facing symmetric NATs, strict firewalls, or when direct peer-to-peer is impossible.
For businesses building advanced communication solutions, integrating a

phone call api

can further enhance your application's voice capabilities, especially in environments where TURN servers are necessary for reliable connectivity.

TURN Server vs VPN

While both TURN servers and VPNs facilitate network traversal, their purposes diverge:
  • TURN Server: Designed specifically for relaying real-time media/data for applications like WebRTC, focusing on NAT traversal and peer connectivity.
  • VPN (Virtual Private Network): Encrypts all network traffic and tunnels it through a secure server, primarily for privacy, security, or accessing remote networks.
TURN is optimized for real-time, low-latency communication and only relays relevant media streams. VPNs, on the other hand, handle all traffic and can introduce higher latency, making them less suitable for real-time applications. Security-wise, TURN supports authentication and encryption, but VPNs provide broader privacy guarantees.
If your application requires both real-time interaction and large-scale broadcasting, leveraging a

Live Streaming API SDK

alongside TURN can help you deliver interactive live experiences with minimal latency.

Implementation: Setting Up a TURN Server

Open-Source and Commercial TURN Server Software

  • coturn: The most popular open-source TURN server, actively maintained and widely supported.
  • Restund, rfc5766-turn-server: Alternative open-source implementations.
  • Commercial options: Twilio, Xirsys, and cloud platforms offer managed TURN services.
When deploying a

Video Calling API

, choosing the right TURN server implementation is crucial for ensuring global reach and high availability.

Basic Setup Steps

  1. Install coturn: bash sudo apt-get update sudo apt-get install coturn
  2. Configure coturn (example config file): ini listening-port=3478 fingerprint use-auth-secret static-auth-secret=your_secret realm=turn.example.com total-quota=100 bps-capacity=0 cert=/etc/ssl/certs/turn_server_cert.pem pkey=/etc/ssl/private/turn_server_pkey.pem no-stdout-log
  3. Start the server: bash sudo turnserver -c /etc/turnserver.conf

Cloud Deployment Overview

  • AWS/GCP/Azure: Deploy coturn on a VM, configure security groups/firewall rules for UDP/TCP 3478 and 5349 (TLS).
  • Managed Services: Use Twilio, Xirsys, or specialized providers for scalability and reliability without managing infrastructure.

Security Considerations for TURN Servers

TURN servers handle sensitive real-time data, making security paramount:
  • Encryption: Use TLS to encrypt traffic between clients and TURN.
  • Authentication: Enforce strong credentials or ephemeral shared secrets.
  • DDoS Protection: Limit allocation quotas and monitor for abuse.
Best practices include regular software updates, logging, and restricting access to trusted networks to reduce attack surfaces in 2025.

TURN Servers in Real-Time Applications

TURN servers power a range of latency-sensitive applications:
  • WebRTC: Video conferencing (e.g., Google Meet, Zoom)
  • VoIP: Voice-over-IP telephony (e.g., Cisco Webex)
  • Online Gaming: Multiplayer game communication and matchmaking
Leading platforms integrate TURN to guarantee seamless user experiences under diverse network conditions. Whether you're building with

webrtc android

,

flutter webrtc

, or other frameworks, TURN servers ensure your real-time communication features work reliably across all devices and networks.

Choosing a TURN Server Provider

When selecting a TURN server provider, consider:
  • Reliability and uptime
  • Global network presence
  • Scalability and bandwidth limits
  • Security features (TLS, authentication)
  • Pricing: Free (coturn), paid (managed providers)
Free open-source options like coturn are suitable for small deployments, while large-scale applications benefit from managed cloud TURN providers offering SLAs and global coverage. For those looking to get started quickly, you can

Try it for free

and explore TURN server integration with leading communication APIs.

Conclusion: The Essential Role of TURN Servers

TURN servers are indispensable for modern real-time communication, providing reliable NAT traversal, security, and interoperability in complex network environments. Whether building next-gen WebRTC apps, deploying cloud-based solutions, or supporting global teams, understanding and leveraging TURN servers in 2025 is essential for robust and seamless connectivity.

Get 10,000 Free Minutes Every Months

No credit card required to start.

Want to level-up your learning? Subscribe now

Subscribe to our newsletter for more tech based insights

FAQ