how to integrate external coturn server with livek...
# ask-ai
g
how to integrate external coturn server with livekit server when doing self-host?
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to use an external Coturn server with a self-hosted LiveKit server — I’ll show the simplest config changes and checklist so LiveKit uses your Coturn for TURN allocations. 1) LiveKit config (livekit.yaml) • Enable TURN and point LiveKit to your TURN domain/ports. Example:
Copy code
turn:
  enabled: true
  udp_port: 3478
  tls_port: 5349
  domain: your-turn-domain.com
  cert_file: /path/to/cert.pem
  key_file: /path/to/key.pem
• If you run LiveKit behind a proxy or load balancer, ensure the domain and certs match what clients will reach. 2) Coturn server basics • Coturn must listen on the ports you declare (commonly UDP 3478 and TLS 5349). • Coturn should be configured to issue time-limited credentials (long-term credential mechanism) so LiveKit can generate ephemeral TURN credentials for clients. • Ensure Coturn has valid TLS certs if you enable TLS. 3) Network / firewall • Open/forward: ◦ UDP 3478 (TURN/UDP) ◦ TCP/UDP 5349 (TURN/TLS and TURN/TCP) ◦ UDP media port range used for relay (commonly 49152–65535 or whatever you configure) • Allow LiveKit server to reach the Coturn server on those ports. 4) Credential flow • LiveKit expects to be able to generate TURN credentials for clients. Configure Coturn to accept the same credential method (shared secret / HMAC time-limited credentials). Confirm your Coturn user/credential setup matches how LiveKit will create credentials. 5) Verify • Start both servers, then from a client behind restrictive NAT verify the client obtains a TURN relay candidate and media flows through the Coturn relay (browser debug tools show TURN candidate and relay IP). • Check LiveKit and Coturn logs for allocation/auth errors. If you’d like, tell me: • Are you running Coturn on a separate VM, same host, or Kubernetes? • Do you want a sample Coturn config snippet for long-term credentials and TLS? Sources: Deploying LiveKit | LiveKit docs
g
yes i am running coturn on separate VM
t
Great — since Coturn runs on a separate VM, here’s a concise checklist and sample configs to get LiveKit using that TURN server. 1) Coturn server (on VM) — key settings (in /etc/turnserver.conf) • Enable long-term credentials and static shared secret for time-limited credentials:
Copy code
lt-cred-mech
  use-auth-secret
  static-auth-secret=<YOUR_SHARED_SECRET>
• Listening ports and TLS (adjust paths):
Copy code
listening-port=3478
  tls-listening-port=5349
  fingerprint
  realm=your-turn-domain.com
  cert=/etc/ssl/certs/turn.crt
  pkey=/etc/ssl/private/turn.key
• Relay port range (example):
Copy code
min-port=49152
  max-port=65535
• Network and security:
Copy code
external-ip=<PUBLIC_IP_OF_VM>   # if behind NAT
  no-stdout-log
  log-file=/var/log/turnserver/turnserver.log
2) LiveKit config (livekit.yaml) • Point LiveKit to the TURN domain and enable TURN. Example:
Copy code
turn:
    enabled: true
    domain: your-turn-domain.com
    udp_port: 3478
    tls_port: 5349
    cert_file: /path/to/cert.pem    # if terminating TLS at LiveKit/proxy
    key_file: /path/to/key.pem
• Ensure LiveKit uses the same
static-auth-secret
value so it can generate valid credentials for clients. 3) Networking & firewall • Open these on the Coturn VM: ◦ UDP 3478, TCP/UDP 5349 ◦ UDP relay range (e.g., 49152–65535) • Allow LiveKit server IP to reach Coturn on those ports. 4) Verify • From a client behind restricted NAT, confirm browser shows a TURN relay candidate and media flows via the Coturn IP. • Check Coturn logs for allocations and auth entries; check LiveKit logs for TURN credential generation. If you want, I can: • Provide a ready-to-use example
turnserver.conf
tuned for your OS. • Show exact LiveKit
turn
config for Kubernetes vs. bare VM. Which would you prefer?
g
how will this work? • Ensure LiveKit uses the same
static-auth-secret
value so it can generate valid credentials for clients.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!