gray-magician-34629
11/26/2025, 6:58 AMtall-airline-16756
11/26/2025, 6:58 AMtall-airline-16756
11/26/2025, 6:59 AMroom.connect() (including any rtcConfig options you pass)
• Browser and OS, and whether you're on a corporate network, VPN, or home network
• Whether your LiveKit instance is cloud-hosted or self-hosted
• Any console logs around the error and whether signaling (WebSocket) connected successfully
In the meantime you can run these quick checks and share results:
• Force TURN-only to see if relay works:
await room.connect(wsUrl, token, { rtcConfig: { iceTransportPolicy: 'relay' } });
• Run the connection checker:
import { ConnectionCheck } from '@livekit/client-sdk';
const checker = new ConnectionCheck({ url: wsUrl, token });
console.log(await checker.checkWebsocket());
console.log(await checker.checkWebRTC());
console.log(await checker.checkTURN());
Send the code and outputs and I’ll dive into the root cause.
Sources: Connecting to LiveKit | LiveKit docs | Configuring firewalls | LiveKit docs | Firewall Tips | Diagnosing Connection Errors with Connection Test Utility | Deploy to a VM | LiveKit docsgray-magician-34629
11/26/2025, 6:59 AMtall-airline-16756
11/26/2025, 6:59 AMroomConfig agents/metadata added before toJwt().
• TTL 15m is fine; returned response includes serverUrl, roomName, and participantToken as expected.
What I need from you (please share)
• The client-side JS where you call room.connect(wsUrl, token) (include any rtcConfig options).
• Browser + OS + network type (home, corporate, mobile carrier, VPN).
• Whether LIVEKIT_URL is a cloud URL (e.g., wss://{instance}.livekit.cloud) or your self-hosted domain.
• Any console logs around connection (signaling/ICE/DTLS) and the exact stack trace for the ConnectionError.
Immediate checks to run now 1) Verify signaling connects:
• Confirm the client successfully opens WebSocket to wsUrl (no auth or CORS error). If signaling fails, the PC won't start.
2) Force TURN-only to test relay:
await room.connect(wsUrl, token, { rtcConfig: { iceTransportPolicy: 'relay' } });
If this succeeds, the issue is UDP/ICE on the network.
3) Run connection checks:
import { ConnectionCheck } from '@livekit/client-sdk';
const checker = new ConnectionCheck({ url: wsUrl, token });
console.log(await checker.checkWebsocket());
console.log(await checker.checkWebRTC());
console.log(await checker.checkTURN());
Share outputs.
4) Network rules to confirm (especially on corporate/NAT):
• Allow TCP 443 to *.livekit.cloud (signaling) and *.turn.livekit.cloud (TURN).
• Allow UDP 50000–60000 for direct media if you want ICE/UDP.
Other quick items to confirm
• If self-hosted: TLS certs and DNS are valid for the LIVEKIT_URL and any TURN domain.
• Client and server clocks are roughly synced (large clock skew can affect auth).
Send the client connect code and the ConnectionCheck outputs and I’ll pinpoint next steps.gray-magician-34629
11/26/2025, 7:07 AMtall-airline-16756
11/26/2025, 7:07 AMnpm i @livekit/client-sdk does not work. Install the correct package:
npm install livekit-client
# or
yarn add livekit-client
Then import and use it, for example:
import { Room } from 'livekit-client';
const room = new Room();
await room.connect('wss://your-server.livekit.cloud', token);
If you want, paste your client-side connect code (how you call room.connect()), browser/OS, and whether you're on a corporate/VPN network — I’ll review next steps for the "could not establish pc connection" error.
Sources: Connecting to LiveKit | LiveKit docs | JavaScript quickstart (web) | LiveKit docs | React quickstart | LiveKit docs | client-sdk-js | livekit/livekit_composite | DeepWikigray-magician-34629
11/26/2025, 7:08 AMtall-airline-16756
11/26/2025, 7:08 AMnpm install livekit-client
import { ConnectionCheck } from 'livekit-client';
2) Create the checker
const checker = new ConnectionCheck({
url: wsUrl, // the same wss://... URL you use for room.connect()
token: token, // token from your server
});
3) Run the basic checks (recommended)
console.log(await checker.checkWebsocket()); // signaling
console.log(await checker.checkWebRTC()); // peer connection ability
console.log(await checker.checkTURN()); // TURN relay reachability
4) Optional checks
console.log(await checker.checkReconnect());
console.log(await checker.checkPublishAudio());
console.log(await checker.checkPublishVideo());
5) Interpret results
• Each result has `status`: 'PASSED' | 'FAILED' | 'SKIPPED'.
• If WebSocket fails → signaling/URL/token issue.
• If WebRTC fails but TURN passes → UDP/ICE is blocked; use TURN.
• If TURN fails → network or blocked access to TURN domains (check TCP:443 to *.turn.livekit.cloud).
6) Quick troubleshooting actions based on results
• If TURN helps, connect with rtcConfig: { iceTransportPolicy: 'relay' } to force relay.
• Confirm wsUrl uses wss:// and token is valid.
• Run checks from the same network (browser) that's failing.
If you run those and paste the three outputs (checkWebsocket, checkWebRTC, checkTURN), I’ll interpret them and give next steps.
Sources: Diagnosing Connection Errors with Connection Test Utilitygray-magician-34629
11/26/2025, 7:10 AMtall-airline-16756
11/26/2025, 7:10 AMthis.url.startsWith is not a function (WebSocketCheck): your url argument is not a string (likely an object).
• navigator is not defined (WebRTCCheck & TURNCheck): you're running ConnectionCheck in a non-browser environment (Node/SSR). ConnectionCheck requires browser WebRTC APIs like navigator and RTCPeerConnection.
What to do next
1. Run ConnectionCheck in the browser (not server/Next.js server code). Example:
import { ConnectionCheck } from 'livekit-client';
const checker = new ConnectionCheck({ url: 'wss://your-server.livekit.cloud', token });
console.log(await checker.checkWebsocket());
console.log(await checker.checkWebRTC());
console.log(await checker.checkTURN());
1. Fix the url value so it's a string (e.g., wsUrl should be 'wss://...', not an object).
2. If you can’t run tests in the browser, use the LiveKit Connection Tester: https://livekit.io/connection-test
If you run the three checks from a browser and paste the outputs here, I’ll interpret them and give targeted next steps. If you want, paste your client-side room.connect(wsUrl, token) call and I’ll check the wsUrl format and options.
Sources: Diagnosing Connection Errors with Connection Test Utility | Configuring firewalls | LiveKit docs | Firewall Tipsgray-magician-34629
11/26/2025, 6:16 PMtall-airline-16756
11/26/2025, 6:16 PM701 STUN host lookup received error: stun:global.stun.twilio.com:3478.
• TURNCheck warns: "No TURN servers configured."
What this means
• Signaling is fine. The peer connection failed to find a usable path because STUN lookups are failing and no TURN relay is available as a fallback. Without TURN, networks that block UDP or have restrictive NAT will fail to establish the media connection.
Next steps (pick applicable)
• If you use LiveKit Cloud: ensure your client wsUrl points to the cloud instance (wss://...) and use tokens from that project — LiveKit Cloud provides TURN automatically. Rerun ConnectionCheck in the browser.
• If self-hosted: configure TURN servers for your LiveKit deployment (or enable LiveKit’s TURN config). Add TURN servers to your LiveKit config so clients receive them in ICE candidates.
• Temporary test: force TURN-only on the client to confirm relay fixes it:
await room.connect(wsUrl, token, { rtcConfig: { iceTransportPolicy: 'relay' } });
• Verify network/firewall:
◦ Allow TCP:443 to *.livekit.cloud and *.turn.livekit.cloud (or your TURN host).
◦ Open UDP 50000–60000 for direct media if you want ICE/UDP.
• Re-run checks in the browser and paste these three results: checkWebsocket, checkWebRTC, checkTURN.
If you tell me whether your LiveKit is cloud-hosted or self-hosted and paste your client room.connect(wsUrl, token, ...) call, I’ll give exact TURN config and follow-up steps.gray-magician-34629
11/26/2025, 6:17 PMtall-airline-16756
11/26/2025, 6:17 PMiceTransportPolicy: 'relay' in the client to confirm TURN relay works.
Quick config example (coturn + LiveKit)
• coturn: configure tls-listening-port=443, listening-ip=PUBLIC_IP, realm=your-domain, user credential or long-term-credentials.
• LiveKit: set turn.uris=["turns:turn.your-domain:443"], turn.username, turn.password, turn.tls=true.
If you tell me:
• whether you’ll use a hosted TURN or self-host coturn, and
• whether LiveKit is cloud or self-hosted behind your LB,
I’ll provide the exact LiveKit config snippet and a minimal coturn config you can apply.gray-magician-34629
11/26/2025, 6:19 PMtall-airline-16756
11/26/2025, 6:19 PMuse-auth-secret in coturn (recommended), configure LiveKit to use TURN credentials that match your credential scheme (static username/password or dynamic credentials depending on your setup).
DNS & ALB notes
• TURN DNS (turn.your-domain.com) must resolve directly to the TURN server's public IP (not the ALB).
• ALB remains in front of LiveKit signaling/websocket endpoints only (wss://). Do not route TURN through the ALB.
• Ensure ALB health checks and stickiness (if used) are configured for LiveKit signaling as needed.
Firewall / Ports
• Allow TCP 443 to:
◦ LiveKit nodes (ALB → LiveKit for signaling)
◦ TURN server (clients → TURN)
• For direct media (optional), allow UDP 50000–60000 to LiveKit nodes.
• Ensure NAT / security groups map PUBLIC_IP → coturn instance.
Testing and verification
1. From browser client run ConnectionCheck (in browser):
◦ checkWebsocket(), checkWebRTC(), checkTURN()
◦ TURNCheck should show your TURN server and pass.
1. Force relay on client to validate TURN:
await room.connect(wsUrl, token, { rtcConfig: { iceTransportPolicy: 'relay' } });
1. Check coturn logs for successful allocations and auths.
Common pitfalls
• TURN domain resolving to ALB (causes failure) — ensure direct DNS to TURN host.
• Invalid TLS certs for coturn or LiveKit (verify with openssl s_client).
• Coturn not bound to public IP / firewall blocking 443.
• Using short-lived tokens or wrong credentials to authenticate to TURN (match mechanism).
If you want, tell me:
• the TURN hostname you plan to use (or confirm it will point to the TURN server public IP),
• whether you’ll use static username/password or long-term secret (use-auth-secret),
and I’ll give the exact LiveKit YAML snippet and a sample coturn.conf tuned for your choices.gray-magician-34629
11/27/2025, 5:42 AMtall-airline-16756
11/27/2025, 5:42 AMlivekit.yaml so clients receive TURN candidates. Below is a concise example and checklist.
Example livekit.yaml TURN section (add under top-level config):
turn:
enabled: true
uris:
- "turns:turn.your-domain.com:443" # TLS/TCP TURN
- "turn:turn.your-domain.com:3478" # UDP TURN (optional)
username: "turn-user" # static username (or omit if using auth-secret)
credential: "turn-password" # password for static creds
tls: true # advertise TLS TURN
If you use coturn long-term-credential secret (recommended)
• In coturn: enable --use-auth-secret / static-auth-secret=YOUR_SECRET.
• In LiveKit YAML, do not set `username`/`credential`; instead LiveKit will generate ephemeral TURN creds using the shared secret. Example:
turn:
enabled: true
uris:
- "turns:turn.your-domain.com:443"
auth_secret: "YOUR_SECRET"
tls: true
Checklist after editing
• Ensure turn.your-domain.com DNS points directly to the coturn EC2 public IP (do NOT point to the ALB).
• Coturn must have a valid TLS cert (for turns: on 443) and be reachable on the ports you advertise.
• Open firewall/security group:
◦ TCP 443 to coturn (clients → TURN)
◦ UDP 3478 (optional) and/or UDP 50000–60000 (if using UDP media directly on LiveKit nodes)
• Restart each LiveKit node after updating livekit.yaml.
Verify
1. From a browser client, run ConnectionCheck checkTURN() and checkWebRTC(). TURNCheck should list your TURN server and pass.
2. Force relay test:
await room.connect(wsUrl, token, { rtcConfig: { iceTransportPolicy: 'relay' } });
1. Check coturn logs for allocations/auth attempts when clients connect.
If you tell me whether you want static username/password or the auth_secret method, I’ll give the exact YAML lines and a minimal coturn.conf snippet for that mode.
Sources: Deploying LiveKit | LiveKit docs | Deploy to Kubernetes | LiveKit docsgray-magician-34629
11/27/2025, 5:45 AMtall-airline-16756
11/27/2025, 5:46 AMturn block used invalid field names. Use LiveKit’s supported schema. Based on the logs earlier you’re running a recent self-hosted server, so update each node’s livekit.yaml turn section to one of these valid options.
If LiveKit should handle TURN/TLS (coturn DNS points to coturn server public IP)
turn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
cert_file: /etc/letsencrypt/live/turn.your-domain.com/fullchain.pem
key_file: /etc/letsencrypt/live/turn.your-domain.com/privkey.pem
If your ALB terminates TLS and forwards plaintext to LiveKit (omit certs)
turn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
Notes and checks
• Do NOT use uris, tls, shared_secret, username, or credential fields in LiveKit config — those caused the YAML parse errors.
• Ensure turn.your-domain.com DNS resolves directly to the coturn EC2 public IP (must NOT point to the ALB).
• Coturn should be configured independently (listening on 443 with valid TLS certs or long-term credential secret).
• Open firewall/security groups:
◦ TCP 443 to coturn (clients → TURN)
◦ TCP 443 to ALB → LiveKit (signaling)
◦ UDP 50000–60000 to LiveKit nodes (if using direct UDP media)
• Mount cert paths into the LiveKit container if you set `cert_file`/`key_file`.
After editing
1. Restart LiveKit containers on each node.
2. From a browser client run ConnectionCheck: checkWebsocket(), checkWebRTC(), checkTURN(). TURNCheck should show your TURN server.
3. For quick verification, force relay:
await room.connect(wsUrl, token, { rtcConfig: { iceTransportPolicy: 'relay' } });
If you want, paste:
• your current turn block (exact lines),
• the LiveKit server version (livekit-server --version),
and I’ll give the exact YAML to apply and a minimal coturn.conf tuned for your setup.
Sources: Ports and firewall | LiveKit docs | Deploy to a VM | LiveKit docsgray-magician-34629
11/27/2025, 6:01 AMtall-airline-16756
11/27/2025, 6:01 AMturn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
cert_file: /etc/letsencrypt/live/turn.your-domain.com/fullchain.pem
key_file: /etc/letsencrypt/live/turn.your-domain.com/privkey.pem
• Ensure those files exist in the container (mount host paths into the container in docker-compose).
• If ALB terminates TLS (recommended with ALB): remove cert_file/key_file and let ALB handle TLS. Example:
turn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
• Important: turn.your-domain.com must resolve directly to your coturn EC2 public IP, not the ALB, because TURN clients must talk to coturn.
2) External IP / STUN warnings
• Logs show LiveKit found external IP via STUN (65.0.72.28) but validation timed out ("context canceled"). LiveKit then used a best-effort list of external IPs.
• Likely causes: transient STUN lookup timeouts, firewall blocking outbound STUN, or short time budget for validation.
• Fixes:
◦ Ensure LiveKit nodes can reach public STUN/TURN servers (UDP/TCP) outbound.
◦ If using coturn for external IP discovery, confirm coturn is reachable and responsive.
◦ Consider setting use_external_ip: true and explicitly providing the public IP in rtc.use_external_ip or rtc.external_ips if NAT is static:
rtc:
use_external_ip: true
external_ip: 65.0.72.28
(Use only if your public IP is static for each node.)
• Open outbound UDP/TCP as needed and retry — STUN validation should then succeed.
3) Coturn + LiveKit notes (quick checklist)
• coturn runs on EC2 public IP with valid TLS certs for turn.your-domain.com.
• DNS: turn.your-domain.com → coturn public IP (not ALB).
• Firewall: allow TCP 443 to coturn; allow UDP 50000–60000 to LiveKit nodes (or use TLS TURN only).
• Mount certs into LiveKit container if LiveKit is serving TURN TLS.
4) Next steps I can do for you
• If you paste your current turn: and rtc: sections from livekit.yaml and your docker-compose mount paths, I’ll give exact corrected YAML and docker-compose volume mappings.
• Tell me if TLS is terminated at the ALB or if LiveKit/coturn should handle TLS.gray-magician-34629
11/27/2025, 6:03 AMtall-airline-16756
11/27/2025, 6:03 AMturn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
• DNS for turn.your-domain.com must point directly to the coturn EC2 public IP (clients talk to coturn). ALB terminates TLS for LiveKit signaling only.
2) LiveKit serves TURN/TLS directly
• Copy or mount the cert files into each LiveKit node and point `cert_file`/`key_file` to local paths inside the LiveKit container:
turn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
cert_file: /etc/letsencrypt/live/turn.your-domain.com/fullchain.pem
key_file: /etc/letsencrypt/live/turn.your-domain.com/privkey.pem
• In docker-compose, mount host cert dir into the container:
volumes:
- /etc/letsencrypt/live/turn.your-domain.com:/etc/letsencrypt/live/turn.your-domain.com:ro
• Ensure certs are valid for the turn domain and restart LiveKit.
Which to choose
• Use option 1 if coturn already has certs and you want a simpler setup (LiveKit nodes do not need certs).
• Use option 2 only if LiveKit must terminate TURN/TLS itself.
Tell me which option you prefer and whether LiveKit or coturn is terminating TLS; I’ll give the exact docker-compose volume mounts and final livekit.yaml snippet.gray-magician-34629
11/27/2025, 6:04 AMtall-airline-16756
11/27/2025, 6:04 AMturn.enabled: true and no TLS termination is configured upstream. Quick options to fix it:
1) Prefered — let coturn terminate TURN/TLS (recommended)
• Keep certs only on the coturn EC2.
• In each LiveKit node's livekit.yaml omit `cert_file`/`key_file` and only set:
turn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
• Ensure DNS for turn.your-domain.com points directly to the coturn EC2 public IP (clients connect to coturn), and coturn has the certs. Restart LiveKit. LiveKit will still advertise TURN, but clients will use the coturn server you configured.
2) If LiveKit must serve TURN/TLS (you chose this), provide certs on every LiveKit node
• Copy or mount the certs into each LiveKit container and set paths in livekit.yaml.
• Example docker-compose volume (host certs on each node):
services:
livekit:
image: livekit/livekit-server:latest
volumes:
- /etc/letsencrypt/live/turn.your-domain.com:/etc/letsencrypt/live/turn.your-domain.com:ro
• livekit.yaml:
turn:
enabled: true
domain: turn.your-domain.com
tls_port: 443
udp_port: 443
cert_file: /etc/letsencrypt/live/turn.your-domain.com/fullchain.pem
key_file: /etc/letsencrypt/live/turn.your-domain.com/privkey.pem
• Restart containers. The cert files must exist inside the container at those exact paths.
Why omitting certs caused the error
• LiveKit detected turn.enabled: true and expected TLS certs for TURN/TLS on that host. If you don’t provide certs and TLS isn’t terminated upstream, LiveKit fails to start.
If you tell me which option you want (coturn handles TLS vs LiveKit handles TLS), I’ll give the exact livekit.yaml and docker-compose changes for your setup and a short checklist to verify.gray-magician-34629
11/27/2025, 6:05 AMtall-airline-16756
11/27/2025, 6:06 AMgray-magician-34629
11/27/2025, 6:07 AMgray-magician-34629
11/27/2025, 6:12 AM