Setting up a coturn or eturnal TURN server for Matrix calls

A TURN server lets one-to-one Matrix calls connect when participants sit behind NATs and firewalls. This page covers the choices, build sequence and tests for coturn or eturnal.

On this page

Why a coturn or eturnal TURN server is needed for Matrix calls

Picture a team whose one-to-one Matrix calls ring on both ends but never connect. The most common cause is that the two devices cannot reach each other directly, because each sits behind a corporate NAT or firewall that blocks unsolicited inbound traffic. A TURN relay is the fallback path that fixes this. Instead of a direct peer-to-peer media path, both clients send their audio and video to a TURN server on the network, which forwards it to the other side. The TURN server is therefore part of the call path whenever direct connections fail, and it is often the only path available inside a locked-down network.

Clients do not find a TURN server on their own. Synapse hands them the TURN details during call setup, including the server addresses, the credentials and how long those credentials remain valid. Those values must match what the TURN server expects. If the Synapse settings point to a host, port or secret that the TURN server does not use, calls still ring but media never flows, and the failure looks like a network problem rather than a configuration error. The relevant Synapse configuration keys are documented in the Synapse configuration manual, and you should confirm the exact key names and value formats against that version before you change anything.

Before you commit to a design, confirm three things with the vendor documentation for the coturn or eturnal release you plan to run: which authentication mode Synapse expects, which ports and relay address range the server must open, and how the TURN server should be reached over TLS and UDP or TCP from your user networks. Those answers decide the firewall work, the shared secret handling and the test plan later in this page. Treat the TURN server as an internet-facing service with its own exposure, since it relays media for any user who obtains valid credentials.

Choosing between coturn and eturnal and their deployment options

This table compares coturn and eturnal on the points that shape a Matrix calling deployment: authentication, configuration, port and relay planning, and operations. The supplied research does not settle most of these points, so the last column tells you what to confirm in each project's documentation before you choose. Treat unconfirmed cells as open questions, not answers.

Decision pointcoturneturnal
Authentication model for SynapseConfirm in the coturn documentation whether the shared secret (static auth secret with time-limited credentials) is the mechanism Synapse's TURN settings expect, and how it is configured.Confirm in the eturnal documentation how shared-secret or time-limited credentials are supported and whether they match Synapse's TURN settings.
Configuration styleConfirm the format of the main configuration file, command-line overrides and whether a reload without restart is supported.Confirm the configuration format and how it is managed as an Erlang-based service in your environment.
Port and relay range planningPlan the listening ports (including TLS listeners) and the relay port range in the firewall. Confirm the default range and the options that restrict relay addresses.Plan the listening ports (including TLS listeners) and the relay port range in the firewall. Confirm the default range and how relay addresses are restricted.
Behavior behind NATConfirm how the external IP is declared when the host sits behind NAT, since misdeclared addresses are a common cause of relay candidates that never work.Confirm how the external IP and relay address are declared behind NAT and whether this differs from coturn's approach.
Operational fitConfirm its maturity, packaging for your operating system and the monitoring hooks it exposes. Many Matrix guides already reference it.Confirm its packaging, release cadence and monitoring hooks, and whether your team already runs Erlang services.
Testing relay candidatesUse a browser-based ICE test to confirm relay candidates appear after the server is configured. The test works the same way for either server.Use the same browser-based ICE test to confirm relay candidates appear. Confirm any admin or metrics endpoints before exposing them.
Support and upgradesConfirm the upgrade notes and security advisories channel for the release you plan to run.Confirm the upgrade notes and security advisories channel for the release you plan to run.

How a one-to-one call reaches the TURN relay

The call starts in the caller's client, which asks the Synapse homeserver for TURN credentials. Synapse issues short-lived credentials derived from the shared secret it shares with the TURN server, so the TURN server can verify them without a database lookup. The client then offers its candidate addresses, and when direct paths fail, traffic is relayed through the TURN server's listening ports and relay range. Check that the relay range and listening ports are reachable through the firewall, and that the shared secret matches on both sides.

Credentials flow from Synapse, and media is relayed through the TURN server across the firewall.

Setup sequence for a TURN server behind Synapse

This sequence takes a TURN server from a DNS name and certificate to a working relay that Synapse hands to clients, with a check at each stage so calls are not the first place a misconfiguration shows up. The output is a TURN host that issues time-limited credentials and relays media for users behind restrictive networks.

  1. Choose the TURN host and its DNS names

    The network or platform engineer picks a host that is reachable from the internet on the TURN ports, ideally separate from the Synapse homeserver, and creates a DNS name for it, such as turn.example.com, that resolves to a public address. Decide whether the TURN host will also be reached over IPv6 and confirm the address family your firewall and NAT rules expect. Confirm the chosen names with your network team before any certificate request. Done when a lookup of the name from outside your network returns the expected public address and the host answers on its public interface.

  2. Issue the TLS certificate for the TURN host

    Obtain a certificate for the TURN DNS name from your certificate authority or internal PKI, and place the certificate and private key where the TURN service can read them, with permissions limited to the service account. TLS on TURN lets clients reach the relay through networks that block other traffic, so confirm the certificate chain is complete and that the key is not world-readable. Done when openssl s_client run against the TURN name and TLS port shows a valid chain and the expected subject name.

  3. Install coturn or eturnal on the host

    The system administrator installs either coturn or eturnal from the operating system packages or the project's release channel, then records the exact version in your change log. Both are TURN servers that Synapse can use for calls, so choose one based on your team's operational preference and confirm current configuration guidance with the project you select. Keep the service disabled until configuration is complete. Done when the binary reports its version and the service unit exists but has not yet started.

  4. Configure the shared secret and listening ports

    Set a long random shared secret on the TURN server and store the same value where Synapse reads its TURN settings, using a secrets manager or a root-only file rather than the main configuration. Configure the listening ports for UDP and TCP, the TLS port, the realm that matches your DNS name, and the relay address range. The shared secret lets Synapse issue short-lived credentials that the TURN server verifies without a user database. Done when the configuration file parses without errors and the service starts and stays running in the foreground test.

  5. Open the listening ports and relay range

    The network engineer opens the TURN listening ports and the UDP relay port range on the host firewall and any upstream security group or NAT, and confirms that the relay addresses the server allocates are routable from the internet. Relay traffic needs its own range in addition to the listening port, so a rule for the listener alone is not enough. Confirm the range with the TURN project's documentation for your version. Done when a test from an external network reaches the listening port and a relay allocation test returns a candidate address inside the range.

  6. Add the TURN settings to Synapse

    The Synapse administrator adds the TURN URIs, the shared secret and the credential lifetime to the homeserver configuration, using the keys documented in the Synapse configuration manual for your release. Use the same DNS name in the URIs that the certificate covers, and list both UDP and TLS variants if you enable them. Keep the secret out of logs and version control. Done when the homeserver configuration validates and Synapse reports no TURN-related errors when it starts.

  7. Restart services and confirm the credential endpoint

    Restart the TURN service and then Synapse so both read the new configuration, and make sure the homeserver is reachable on its client endpoint. Request TURN credentials for a test account through the client API that returns the TURN server list and confirm the response includes your URIs and a time-limited username and password. Done when the credential request returns your TURN URIs and the TURN service logs show the server listening on the expected ports without authentication errors.

  8. Test relay candidates across a restrictive network

    Run a call between two test accounts on different networks, one of which blocks direct peer traffic if you can arrange that, and use the browser's WebRTC internals page to confirm that a relay candidate is selected and the connection reaches the connected state. Record the candidate types and the port used. If only host or server reflexive candidates appear, the relay path is not working and the firewall, realm or secret needs review. Done when the connection shows a relay candidate in the selected pair and the call stays connected for the test period.

Securing the shared secret, relay range and admin exposure

A TURN server relays media for anyone who can authenticate to it, so its credentials, the addresses it will reach and the hosts around it define how much damage a leak or misconfiguration can cause. The cards below pair each risk with the control that limits it and the check that confirms the control is in place.

Shared secret used for ephemeral credentials

Synapse hands clients short-lived TURN credentials derived from a shared secret that the TURN server also holds. Anyone who reads that secret can mint credentials and push traffic through your relay. Store it in a secrets manager or a root-readable file outside the repository, set file permissions so only the service user can read it, and confirm that the value on the Synapse side and the TURN side match after every change. Ask your vendor or project docs which auth mode and secret key name your chosen server expects.

Peer addresses the relay can reach

Without restrictions, a relay can be used to reach internal hosts, cloud metadata endpoints or other services on your network. Configure the server to deny relay access to private, loopback and link-local address ranges, and limit the allowed peer range to what your clients need. Confirm the rules with a test that tries to relay toward an internal address and fails. Review the exact option names in the documentation for the server you deploy.

Relay port range exposure

The relay needs a range of UDP ports open for media, and every open port is part of the attack surface. Keep the range as narrow as your concurrent call volume requires, open it only on the TURN host, and confirm the firewall allows exactly the listener ports and relay range you documented. Record the chosen range so that firewall rules, cloud security groups and monitoring stay consistent when someone changes the configuration later.

TURN host separate from the homeserver

Running the relay on the same host as Synapse means a flaw in the relay can expose the homeserver database, signing keys and admin endpoints. Place the TURN server on its own host or network segment, with only the ports Synapse and clients need reachable. Confirm that the homeserver's admin and replication listeners are not reachable from the TURN network, and that the TURN host holds no database credentials it does not need.

Admin and management interfaces

Some TURN servers offer a command line or administrative interface alongside the relay. Leaving it bound to a public address invites takeover of the relay. Bind any management interface to localhost or a restricted management network, protect it with authentication, and confirm with a port scan from outside the network that it is not reachable. Check the server documentation for which admin options are available and whether they are enabled by default in your release.

Logging, rotation and review

Relay logs show who requested credentials and which peers were reached, which matters for incident response and for data protection reviews. Decide how long relay logs are kept, who can read them, and where they are shipped. Rotate the shared secret on a schedule your security team approves and after any suspected exposure, updating Synapse and the TURN server together. Ask your security team to define the retention period and rotation interval before go-live.

Testing that calls use relay candidates

End users can check which candidates their browser gathers without any server access. Modern browsers expose the WebRTC connection details through internal diagnostic pages, and the candidate types show whether the browser found a path through the TURN server. The check is most useful when a user is on a different network from the office, such as a home connection or a mobile hotspot, because that is where a missing relay path shows up.

  • Open the WebRTC internals page: In Chromium-based browsers, open chrome://webrtc-internals during or after a test call and look at the local candidate list.
  • Look for relay entries: A candidate with type relay means the browser reached the TURN server and received an allocation.
  • Compare with host and srflx entries: host candidates are local addresses and srflx candidates come from STUN, so both can appear even when relay is available.
  • Repeat on a restricted network: Test from a network that blocks direct UDP to confirm the relay path is used when direct routes fail.
  • Record the browser and network: Note the browser version, network type and whether the call connected, so operators can reproduce the result.

If no relay candidate appears from any network, pass the browser output to the operator before asking users to retry.

Limits and items to confirm in your environment

A TURN server for Matrix calls depends on versions, network paths and usage assumptions that change over time. The cards below list what to confirm before go-live, and each one should be checked against the current project documentation rather than against this page.

Exact coturn and eturnal versions

Pick the TURN implementation and the exact release you will deploy, then read its current release notes and configuration documentation for that version. Option names, default ports and authentication behavior can change between releases, so the configuration in your runbook should be tested against the version you install, not copied from examples. Record the version in your change log so later upgrades start from a known baseline.

Synapse version and platform floors

Confirm which Synapse release your homeserver runs and read the upgrade notes for every release between your current version and the target. Synapse documents minimum PostgreSQL and Python versions for recent releases, and it drops support for platforms once they reach upstream end of life. A TURN rollout does not fix an out-of-support database or runtime, so check those floors before changing the call settings.

Synapse upgrade notes

IPv6 handling

Decide whether your TURN server listens on IPv6, relays IPv6 candidates, or both, and confirm that your DNS records, firewall rules and cloud security groups match that decision. Clients may gather IPv6 candidates that your network cannot route, which can lead to failed or slow calls. Test from networks that use IPv4 only and from dual-stack networks so you know which paths actually work.

Bandwidth and relay capacity

Relayed media uses server bandwidth in both directions for the full length of each call, so the relay path must be sized for expected concurrent calls, not only for the number of users. Ask your network team for the uplink available at the TURN host, the number of simultaneous relayed sessions you plan to allow, and the per-session limits your TURN software supports. Monitor relay usage from the first pilot so capacity is based on measured traffic.

Whether one-to-one calls are the only use

Confirm whether the TURN server will serve only one-to-one calls or also group calls, other Matrix clients, or other applications. Group calling with Element Call uses a separate media service, so a TURN server sized for direct calls does not cover that load. If other applications will share the same relay, add their traffic to the capacity estimate and review the shared secret and port ranges for each use.

Ports and firewall scope

List every port your TURN server and its relay range need, then confirm which of them your firewalls, load balancers and cloud groups allow from client networks. Blocked relay ports are one of the most common causes of calls that ring but never connect, so verify the path from outside your network, not only from the server itself. Document any port that the default configuration opens but your policy forbids.

Questions teams ask about TURN for Matrix calls

What drives the cost of setting up a TURN server for Matrix calls?

The cost depends mostly on how much of the work your own team can absorb and how much of it a partner must carry. The main components are network and firewall design, DNS and certificate work, coturn or eturnal configuration, Synapse settings, and testing across the networks your users actually work from. Expect a one-time build cost and a recurring cost for patching, certificate renewal, monitoring, and capacity changes. Costs rise with the number of networks and regions involved, strict corporate firewalls, the need for a relay port range that your security team must approve, and any requirement to test from managed devices. Ask any quote to list each of these as a separate line so you can see what is one-time and what recurs.

How long does a TURN server build usually take?

Duration depends on approvals and environment more than on the software itself. A single TURN host with a standard certificate and an open firewall path is a short technical job, while most of the elapsed time usually goes to change requests, firewall rule reviews, DNS changes, and certificate issuance. Testing is also iterative, because relay candidates often fail first on one network and pass on another. Ask any proposal to state its assumptions about your change process, the number of test networks, and who owns each approval, and to tie the timeline to written milestones.

What must our internal team provide before a TURN build starts?

Your team provides the environment and the decisions, and the build depends on them. You need a host or virtual machine with a public address, a DNS name that resolves to it, a valid TLS certificate for that name, and firewall changes that allow the TURN listening ports and the relay port range to pass in both directions. You also need a decision on where the shared secret is stored and how Synapse reads it, plus access to the Synapse configuration and a way to restart it during a maintenance window. Confirm the required ports and address ranges with your own network and security teams, since they vary by environment.

Can our own team set up a TURN server without a partner?

Yes, a team with Linux administration, DNS, TLS, and firewall experience can usually do it, and the official coturn and eturnal documentation covers the core configuration. The skills that are often thin are verification and operations: proving that relay candidates are actually used from restricted networks, keeping the relay port range and secret handling correct, and patching on a schedule. A partner is most useful when the internal team lacks time, when the network path is complex, or when the result must be documented for a compliance or security review. Whichever route you take, agree on who owns patching and monitoring after go-live.

What operational risks should we plan for once TURN is live?

The main risks are misconfigured relay ports that block calls only on some networks, expired certificates that break TLS-based TURN, a shared secret that leaks or drifts from the Synapse setting, and a server that is reachable from the internet but not patched. Relay traffic also consumes bandwidth and can be abused if the server is open to unauthorized use, so access controls and rate limits matter. Plan for monitoring of certificate expiry and relay usage, a documented secret rotation procedure, and a tested rollback. Ask any operator to show how these are covered in their runbook.

When is a TURN server not enough, and we need a different service for group calls?

A TURN server relays media for a one-to-one call between two participants. It does not manage group calls, where each participant sends media to a central point rather than to every other participant. For group calling on Matrix, Element Call uses LiveKit as a selective forwarding unit together with an authorization service, and those components have their own configuration, credentials, and reverse proxy paths. Teams that expect group meetings, screen sharing with many viewers, or large calls should plan for LiveKit and the MatrixRTC authorization service from the start, and treat TURN as one part of the calling stack. Confirm with your Synapse and Element versions which calling features they support.

Does a TURN server meet a compliance requirement on its own?

No. A TURN server is a network component, and it does not by itself satisfy an encryption, logging, or access control requirement that your assessor applies to chat or calls. Auditors look at how the server is configured, who can access it, how secrets and certificates are managed, what is logged, and how changes are approved. DeployOpen prepares systems, controls, and evidence for compliance assessments, but independent auditors and certification bodies issue any audit report or attestation. Ask your assessor early which evidence they expect for the calling path.

Deciding when a TURN server is the right fix

The path starts at a call that rings but never connects. First check whether the call is one-to-one, because TURN is what one-to-one calls need when peers cannot reach each other directly. Next, look at the connection candidates the client gathers: if no relay candidates appear, the TURN server is not being offered to the client, and Synapse settings are the place to look. If relay candidates appear but the call still fails, check that the TURN server is reachable on its ports from the client's network. When those checks pass, the problem usually lies elsewhere, so follow the connecting troubleshooting topic.

Decision path for choosing a TURN fix when a one-to-one call will not connect.

How DeployOpen scopes and supports a TURN deployment

DeployOpen is a Chainscore Labs company that plans, implements, hardens and documents self-hosted open-source platforms inside the client's own infrastructure, including cloud accounts, data centers and air-gapped networks. For a TURN deployment, that means the relay host, its network placement, the TLS certificate handling, the Synapse integration and the test evidence all run in your environment under your change control. DeployOpen does not host the relay on its own systems, and it does not issue audit reports or certifications for the result. Independent auditors and certification bodies handle those decisions.

Most engagements are fixed-scope, so the scope, deliverables and timeline are agreed in writing before any work starts. For this topic, the written scope should name the TURN implementation (coturn or eturnal), the hosts and operating systems, the firewall and cloud security group changes, the shared secret handling and rotation approach, the Synapse configuration changes, the relay candidate tests and the handover documentation. A quote follows from that written scope. Ask for it to separate one-time work, such as the initial build and testing, from recurring costs, such as the infrastructure you pay for and any ongoing support. Confirm with DeployOpen which of those items are included before you compare quotes.

Once the relay is live, traffic patterns, certificate renewals, software releases and changes in your network can all affect call success. DeployOpen offers ongoing support, upgrades and continuous testing as a retainer, so the team that built the relay can keep it current and retest relay candidates after changes. Ask what the retainer covers, how change requests are handled, how incidents are reported and what response expectations are written into the agreement. If you plan to run the relay with your own staff, ask for the runbook and test scripts as part of the deliverables so your team can operate it without depending on a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.