Set Up External TURN for Jitsi Behind NAT

When Jitsi is behind NAT, remote users may join a meeting but fail to establish media. Put coturn on a publicly reachable host, advertise its correct public address, and let Prosody provide time-limited TURN credentials. These steps cover package-based Debian or Ubuntu Jitsi; Docker uses different settings.

Network diagram showing a Jitsi server behind a private network and a separate public TURN host relaying media
Illustrative topology: Jitsi handles meeting signaling while the separate public TURN host relays media when a direct path fails.

What to prepare

TURN (Traversal Using Relays around NAT) relays media when a firewall blocks a direct route. It does not replace Jitsi Videobridge (JVB), which carries group-call media. Jitsi documents TURN as a fallback for one-to-one peer-to-peer calls.

Prepare a publicly reachable TURN host and DNS name such as turn.example.net. Record its public and private addresses, your Jitsi domain, and a relay UDP range. The sample uses documentation-only addresses 203.0.113.10 and 10.0.0.20; replace them with your own.

  • Create an A/AAAA DNS record for the TURN hostname that points to the public address clients can reach.
  • Allow and forward TURN listener and relay ports through every firewall, cloud security group, and NAT device in the path.
  • Generate a long random shared secret. Configure coturn and Prosody with the same secret, and keep it out of client-visible files and logs.
  • Make a backup of the Prosody virtual-host configuration and coturn configuration before changing them.

1. Configure coturn for the public NAT address

On the TURN host, install coturn using your distribution’s package manager, then edit its configuration, commonly /etc/turnserver.conf. Confirm the actual path and service name for your distribution. A minimal example is:

listening-port=3478
tls-listening-port=5349
min-port=49160
max-port=49200

fingerprint
lt-cred-mech
use-auth-secret
static-auth-secret=REPLACE_WITH_A_LONG_RANDOM_SECRET
realm=turn.example.net
server-name=turn.example.net

# Only when coturn itself is behind one-to-one NAT:
 listening-ip=10.0.0.20
relay-ip=10.0.0.20
external-ip=203.0.113.10/10.0.0.20

Replace both example addresses and the secret. The external-ip=public/private mapping is specifically for a TURN server behind NAT: coturn must return a reachable public relay address while binding relay sockets to its local interface. Do not set this mapping merely because the Jitsi server is behind NAT if coturn itself has a directly assigned public address. coturn’s documentation also requires NAT to preserve the same external and internal relay port numbers.

Terminal configuration example for coturn listener ports, relay range, shared secret authentication, and realm
Illustrative coturn settings: standard listener ports, a bounded relay range, and secret-based authentication.

2. Open the listener and relay ports

For the example configuration, permit UDP and TCP 3478, TCP 5349 for TURN over TLS, and UDP 49160–49200 for allocated media relays. Forward each port to the TURN host without changing the port number. If you disable a transport, do not open its unused listener. If clients must use TLS, install a valid certificate for turn.example.net and configure coturn’s certificate and private-key paths; the certificate hostname must match the advertised TURN hostname.

Do not expose coturn’s control interface. Size the relay range for your expected use, and allow it in both host and upstream firewalls. A cloud VM still needs matching security-group rules.

Example network firewall rules forwarding TURN listener and relay ports to a private TURN server address
Illustrative forwarding rules: listener ports and the complete relay range must reach coturn with port numbers preserved.

3. Advertise TURN to Jitsi through Prosody

For a package-based Jitsi deployment, edit the Prosody configuration for the Jitsi virtual host, usually /etc/prosody/conf.d/meet.example.net.cfg.lua. Add the TURN services to the existing global settings or the appropriate Jitsi virtual-host scope as required by your installed Prosody/Jitsi configuration. Do not create a second conflicting external_services definition. Example:

external_service_secret = "REPLACE_WITH_A_LONG_RANDOM_SECRET"
external_services = {
  {
    type = "turn",
    host = "turn.example.net",
    port = 3478,
    transport = "udp",
    secret = true,
    ttl = 86400,
    algorithm = "turn",
  },
  {
    type = "turns",
    host = "turn.example.net",
    port = 5349,
    transport = "tcp",
    secret = true,
    ttl = 86400,
    algorithm = "turn",
  },
}

Prosody’s mod_external_services uses external_service_secret for both entries, with secret = true requesting time-limited credentials. The sample follows Jitsi’s Prosody configuration format. Confirm the module is enabled for your Jitsi domain; custom or older installations may differ. The default credential lifetime is one day; adjust ttl if needed. If you do not offer TURN over TLS, remove the second entry and do not advertise it.

For coturn, use-auth-secret and static-auth-secret must match the Prosody service secret exactly. Do not put a permanent username and password in config.js: Jitsi warns that static client-side credentials can be copied and abused to consume relay bandwidth. Restart coturn and Prosody after validating their configuration with the checks available for your installed versions.

4. Check the NAT mapping and restart services

Ensure the DNS record resolves from an external network, and verify the public-to-private forwarding on the router or cloud network. For coturn behind NAT, preserve every relay port one-to-one: external UDP 49160 must reach internal UDP 49160, and so on. A listener may answer on 3478 even when media fails because the relay range is blocked or coturn advertises a private address.

Illustrative ICE candidate diagnostics showing host, server-reflexive, and relay candidate categories
Illustrative ICE diagnostics: a relay candidate should appear when TURN is offered and the test actually requires relaying; shown values are examples, not measured results.

Verify the fix from outside your network

  1. Use a device on a different internet connection, such as cellular data, to join a test room. Testing only from the same LAN can hide NAT and hairpin-routing problems.
  2. Open the browser’s WebRTC internals or the Jitsi client’s available connection diagnostics. Confirm that the session receives a relay candidate for the TURN hostname or its resolved public address. A relay candidate may not be selected when a direct path succeeds, so test with restrictive networks or a controlled ICE test before concluding TURN is broken.
  3. Check coturn logs for allocations during the test; successful authentication and bidirectional media are stronger evidence than an open-port scan.
  4. If authentication fails, compare the Prosody and coturn secrets, domain/realm, and clock synchronization. If authentication succeeds but media fails, check the public/private mapping and every port in the relay range.

A correct setup provides a reachable fallback for restrictive networks while preserving Jitsi’s normal paths. If your deployment is the official Docker Compose stack, configure the documented TURN_HOST, TURN_PORT, TURN_TRANSPORT, or TURNS_HOST/TURNS_PORT variables in its environment instead of editing a package host’s Prosody files; follow the documentation for the exact image version in use.

Official references

Leave a Comment

Set Up External TURN for Jitsi Behind NAT

Set Up External TURN for Jitsi Behind NAT

Configure coturn, NAT port forwarding, and Prosody so Jitsi can relay calls when direct media connections fail.

Why Do Americans Spend Billions on Holiday Shopping While Complaining About Inflation? A 5-Step Analysis

Why Do Americans Spend Billions on Holiday Shopping While Complaining About Inflation? A 5-Step Analysis

Master a 5-step guide to understand holiday inflation spending, balance family traditions with budget realities, and safeguard your finances.

Set Up Jitsi Meet on Ubuntu 24.04 with Trusted HTTPS

Set Up Jitsi Meet on Ubuntu 24.04 with Trusted HTTPS

Install Jitsi Meet from its official Ubuntu packages, obtain a Let’s Encrypt certificate, open the right ports, and verify secure meetings.

How Giving Tuesday Donations Work Behind the Scenes: A Step-by-Step Guide

Discover what happens behind the scenes of Giving Tuesday donations across 6 detailed steps, from payment gateways to matching fund delivery.

Lower Jitsi Meet CPU Use by Reducing Video Decode Load

Lower Jitsi Meet CPU Use by Reducing Video Decode Load

Reduce browser CPU spikes in Jitsi Meet by limiting incoming video, tuning camera use, checking hardware acceleration, and testing the result.

Brand BigBlueButton Meetings with Your Logo and Client Name

Brand BigBlueButton Meetings with Your Logo and Client Name

Set a meeting title, enable the logo area, and choose a default or per-meeting logo on a self-hosted BigBlueButton server.

How to Use AI Shopping Assistants for Holiday Sales Without Missing Better Deals

How to Use AI Shopping Assistants for Holiday Sales Without Missing Better Deals

Use this 4-step guide to compare AI shopping help with holiday sales, verify prices, and choose gifts with confidence this December.

Connect Moodle to BigBlueButton and Test a Live Class

Connect Moodle to BigBlueButton and Test a Live Class

Set up the Moodle activity, add the matching BigBlueButton endpoint and shared secret, then verify teacher, student, and media access.

What to Avoid Saying or Doing When Visiting the U.S. During the Holiday Season: Step-by-Step Etiquette Guide

Master U.S. holiday etiquette in 5 clear steps, avoiding conversation faux pas, tipping mistakes, and host blunders for a smooth, festive trip.

Give Your Jitsi Docker Server a Secure Custom Domain

Give Your Jitsi Docker Server a Secure Custom Domain

Point a Jitsi Meet Docker hostname to your server, configure PUBLIC_URL and HTTPS, then verify browser access and media.