c
hi
t
Thanks for reaching out, Arun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — welcome! How can I help you today? If you’re not sure where to start, tell me what you’re trying to do (e.g., set up a room, connect a client, troubleshoot an error, billing question), and include any relevant details like project ID, room name, SDK (web/iOS/Android), and any error messages.
c
i have clean untunyu machin i ned to just deploey livkeit server
t
You're on a clean Ubuntu machine and want to deploy LiveKit — I can guide you. Quick question first so I give the right steps: • Do you want the recommended Docker Compose + Caddy VM deployment (automatic TLS), or a manual binary/docker-only install? • Do you have a domain name ready and DNS control for an A record to point to this VM? • Which cloud or provider (if any) are you using, or is this a local/on-prem VM? Answer those and I’ll give precise, step-by-step commands. Sources: Deploy to a VM | LiveKit docs
c
i ahve domain just hepl me witl fukl config
t
Great — since you have a domain, I’ll give a full, runnable deployment for a clean Ubuntu VM using the recommended Docker Compose + Caddy option (automatic TLS via Let’s Encrypt). Follow these steps on your local machine and the Ubuntu VM. Prerequisites • A domain (e.g., example.com). I’ll use livekit.example.com as the hostname — replace with your hostname. • DNS A record: point livekit.example.com → your VM public IP. • A clean Ubuntu VM (18.04+/20.04/22.04). • SSH access to the VM. Step 1 — generate config files (run locally) 1. On your local machine run:
Copy code
docker pull livekit/generate
   docker run --rm -it -v $PWD:/output livekit/generate
1. When prompted, enter your domain (e.g., livekit.example.com). The command creates an output folder containing: ◦ docker-compose.yaml ◦ livekit.yaml ◦ caddy.yaml ◦ init_script.sh (and/or cloud_init.ubuntu.yaml) Step 2 — copy files to the VM 1. Copy the generated folder to your VM (adjust username, IP, and path):
Copy code
scp -r ./livekit-output user@YOUR_VM_IP:/home/user/
1. SSH into the VM:
Copy code
ssh user@YOUR_VM_IP
   cd /home/user/livekit-output
Step 3 — run the init script (recommended) 1. Make the script executable and run it with sudo:
Copy code
sudo chmod +x init_script.sh
   sudo ./init_script.sh
The script will: • Install Docker & Docker Compose (if missing) • Create /opt/livekit and place the generated configs • Start the LiveKit Docker stack (systemd service named
livekit-docker
) If your provider supports cloud-init you can instead paste cloud_init.ubuntu.yaml into the provider’s user-data field when creating the VM — the VM will auto-run the same setup. Step 4 — open required firewall ports Run these on the VM (ufw example):
Copy code
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 7881/tcp
sudo ufw allow 3478/udp
sudo ufw allow 50000:60000/udp
sudo ufw enable
Step 5 — verify DNS and TLS 1. Ensure your DNS A record points to the VM IP. 2. Wait a few minutes while Caddy obtains certificates. 3. Test:
Copy code
curl -v https://livekit.example.com
You should get a response from Caddy/LiveKit (replace hostname). Step 6 — where credentials live • The generated
livekit.yaml
contains keys:
api_key
and
api_secret
used to mint tokens. They’ll be placed into the Docker environment by the generated compose files. Keep
api_secret
safe. • Service URL for clients:
wss://livekit.example.com
(or
https://
for REST calls). Step 7 — useful commands on the VM • Check service status:
Copy code
sudo systemctl status livekit-docker
• View Docker containers:
Copy code
docker-compose -f /opt/livekit/docker-compose.yaml ps
• View LiveKit logs:
Copy code
docker logs -f livekit
(container name may vary;
docker ps
to find exact name) Step 8 — test a client connection • Generate a token on your backend using `api_key`/`api_secret` (the generator output includes example code). • Use the Web SDK with
wss://livekit.example.com
to connect to a room and publish media. Troubleshooting quick tips • If TLS fails, ensure ports 80 and 443 are reachable from the internet and DNS is correct. • If WebRTC connectivity is poor, confirm UDP range 50000–60000 and 3478/UDP are open and not blocked by cloud provider. • If containers don’t start, check
/opt/livekit
for config files and
docker-compose
output. If you want, I can: • Provide the exact contents of the typical generated
docker-compose.yaml
and
livekit.yaml
(replace placeholders with your domain and secrets). • Walk through generating tokens with sample code for your backend language (Node/Python/Go). Which would you like next?
c
i need to setup from scratch docker also
t
Great — I’ll give a concise, runnable step-by-step you can run on a clean Ubuntu VM to install Docker/Docker Compose and deploy LiveKit with Caddy (automatic TLS). Replace
livekit.example.com
and
YOUR_VM_IP
with your domain and VM IP. 1) Prepare DNS • Create an A record:
livekit.example.com
→ YOUR_VM_IP 2) SSH to the VM
Copy code
ssh user@YOUR_VM_IP
sudo -i
3) Update system and install prerequisites
Copy code
apt update && apt upgrade -y
apt install -y ca-certificates curl gnupg lsb-release git
4) Install Docker Engine
Copy code
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
5) Enable Docker
Copy code
systemctl enable --now docker
6) Install Docker Compose v2 (if not provided by package)
Copy code
curl -SL "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
(If
docker compose
works already, you can skip this step.) 7) Create LiveKit deploy folder
Copy code
mkdir -p /opt/livekit
cd /opt/livekit
8) Generate LiveKit config locally (recommended) — run this on your local machine, not the VM:
Copy code
docker pull livekit/generate
docker run --rm -it -v $PWD:/output livekit/generate
When prompted, enter your domain
livekit.example.com
. This creates
docker-compose.yaml
,
livekit.yaml
,
caddy.yaml
, and
init_script.sh
in your current folder. If you prefer to create files directly on the VM, you can copy the generated files to
/opt/livekit
(next step). 9) Copy generated files to VM (from local machine)
Copy code
scp -r ./livekit-output/* user@YOUR_VM_IP:/opt/livekit/
ssh user@YOUR_VM_IP
cd /opt/livekit
10) Or use a prepared minimal set (if you want me to paste exact file contents, I can). The generated
docker-compose.yaml
will run LiveKit + Caddy. Ensure
livekit.yaml
contains your `api_key`/`api_secret`. 11) Run the provided init script (or start services manually)
Copy code
chmod +x /opt/livekit/init_script.sh
sudo /opt/livekit/init_script.sh
This installs docker components (if missing), writes configs to
/opt/livekit
, and starts the
livekit-docker
service. If you prefer manual start:
Copy code
cd /opt/livekit
docker compose up -d
12) Open firewall ports (ufw example)
Copy code
apt install -y ufw
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 7881/tcp
ufw allow 3478/udp
ufw allow 50000:60000/udp
ufw --force enable
13) Verify • Wait a few minutes for Caddy to obtain TLS. • Test:
Copy code
curl -v https://livekit.example.com
• Check services:
Copy code
systemctl status livekit-docker
docker compose ps
docker logs -f livekit
14) Client connection info • WebSocket URL: wss://livekit.example.com • REST URL: https://livekit.example.com • Use the
api_key
and
api_secret
from
livekit.yaml
to mint tokens on your backend. If you want, I can now: • Paste the typical contents of
docker-compose.yaml
,
livekit.yaml
, and
caddy.yaml
with placeholders you replace, or • Provide a ready-to-run
init_script.sh
you can paste and run on the VM. Which do you prefer?
c
what si turn server and use of it
t
You're asking what a TURN server is and why you need it — here’s a concise explanation. • What it is: TURN (Traversal Using Relays around NAT) is a relay server for WebRTC media. When two clients cannot form a direct peer-to-peer connection because of NATs or restrictive firewalls, media is sent via the TURN server instead. • Why LiveKit uses it: TURN guarantees connectivity in environments that block or restrict UDP or non-HTTPS traffic (e.g., corporate networks, symmetric NATs). LiveKit includes an embedded TURN server that’s protected by the same authentication as signaling, so only authenticated clients can use it. • How it helps clients connect: a. Clients try direct ICE/UDP first (low latency). b. If that fails, they fall back to TURN/UDP. c. If UDP is blocked, they use TURN over TLS (TCP on 443) which looks like regular HTTPS traffic and passes strict firewalls. • Practical notes for your deployment: ◦ Open ports: 3478/UDP (or 443/UDP), and UDP range 50000–60000. Also keep 80/443 for Caddy TLS. ◦ Use TURN over TLS on port 443 if you expect very restrictive networks. ◦ TURN requires a valid TLS certificate and a reachable domain (e.g., turn.yourdomain.com) if using TURN/TLS. ◦ LiveKit’s embedded TURN uses your LiveKit auth (no separate TURN credentials needed). If you want, I can: • Add TURN configuration to your generated
livekit.yaml
and
caddy.yaml
with the correct ports and domain, or • Show a minimal TURN config snippet you can paste into
/opt/livekit/livekit.yaml
. Which option do you prefer? Sources: Deploying LiveKit | LiveKit docs | Ports and firewall | LiveKit docs | Connecting to LiveKit | LiveKit docs | Deploy to a VM | LiveKit docs
c
give me fresh fulll setup on my vm new vm
t
Below is a single, complete, runnable guide to deploy LiveKit on a fresh Ubuntu VM (18.04/20.04/22.04). It installs Docker/Docker Compose, configures LiveKit + Caddy for automatic TLS, enables TURN, opens required firewall ports, and starts the service. Replace livekit.example.com and turn.livekit.example.com with your domain/subdomain and YOUR_VM_IP with the VM IP. Before you start • Make an A record: livekit.example.com → YOUR_VM_IP • (Optional but recommended) Make an A record: turn.livekit.example.com → YOUR_VM_IP • SSH access to the VM Step A — SSH to the VM and become root
Copy code
ssh user@YOUR_VM_IP
sudo -i
Step B — Update system and install prerequisites
Copy code
apt update && apt upgrade -y
apt install -y ca-certificates curl gnupg lsb-release git ufw
Step C — Install Docker Engine and Docker Compose
Copy code
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl enable --now docker
# Install standalone docker-compose if needed
if ! command -v docker-compose >/dev/null 2>&1; then
  curl -SL "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  chmod +x /usr/local/bin/docker-compose
fi
Step D — Create deploy folder and download LiveKit generator (optional local generate) You can generate config locally (recommended) or create files directly on VM. The generator tool runs in Docker locally and creates correctly configured files. If you prefer to generate on your workstation, run the docker commands there and copy files to /opt/livekit. If you want to do everything on the VM, continue below to create sample files. Create folder:
Copy code
mkdir -p /opt/livekit
cd /opt/livekit
Step E — Create production configs (paste the following files, replacing placeholders) 1) docker-compose.yaml
Copy code
version: "3.8"

services:
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - livekit_net

  livekit:
    image: livekit/livekit-server:latest
    restart: unless-stopped
    environment:
      - LIVEKIT_CONFIG=/livekit/livekit.yaml
    volumes:
      - ./livekit.yaml:/livekit/livekit.yaml:ro
    networks:
      - livekit_net
    ports:
      - "7881:7881" # optional public TCP port for WebRTC if needed

volumes:
  caddy_data:
  caddy_config:

networks:
  livekit_net:
    driver: bridge
2) caddy/Caddyfile
Copy code
# Replace livekit.example.com and turn.livekit.example.com
livekit.example.com {
  reverse_proxy /ws*/* 127.0.0.1:7881
  reverse_proxy /* 127.0.0.1:7880
  log {
    output file /data/caddy/access.log
  }
}

# If you want a dedicated TURN domain for TLS-on-443 TURN
turn.livekit.example.com {
  reverse_proxy 127.0.0.1:5349
}
3) livekit.yaml Replace API_KEY and API_SECRET with strong values (random). Use your domain names.
Copy code
server:
  rtc_port: 7881
  http_port: 7880
  name: livekit-server

keys:
  - key: "API_KEY"
    secret: "API_SECRET"

turn:
  enabled: true
  # Use TLS TURN on 443 if you want TURN over TLS reachable on 443.
  # If using dedicated turn subdomain and Caddy fronting, set tls_port to 5349 or 443.
  tls_port: 5349
  domain: turn.livekit.example.com
  # caddy will handle TLS, so cert paths are not needed when using Caddy
  # For embedded certs (optional), set cert_file/key_file paths here.
  udp_port: 3478
  # UDP relay port range for media
  relay_udp_min_port: 50000
  relay_udp_max_port: 60000

log:
  level: info
Step F — Ensure permissions and run Docker Compose
Copy code
chown -R root:root /opt/livekit
cd /opt/livekit
docker compose up -d
Step G — Open firewall ports
Copy code
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 7881/tcp
ufw allow 3478/udp
ufw allow 50000:60000/udp
ufw --force enable
Step H — Wait for TLS and verify • Wait a few minutes for Caddy to obtain TLS certificates for livekit.example.com (and turn.livekit.example.com if created). • Test:
Copy code
curl -v https://livekit.example.com
• Check containers:
Copy code
docker ps
docker logs -f $(docker ps --filter "ancestor=livekit/livekit-server" --format "{{.Names}}")
• Check Caddy logs in /var/lib/docker/volumes/<compose_project>_caddy_data/_data or via docker logs for the caddy container. Step I — Token generation and client connection • Use
API_KEY
and
API_SECRET
from
livekit.yaml
to mint join tokens in your backend. Client connect URL: wss://livekit.example.com (signaling over WebSocket). • REST API base: https://livekit.example.com TURN notes (important) • TURN relays media when direct connections fail. For best coverage in restrictive networks: ◦ Use TURN over TLS on port 443 (set
tls_port: 443
and ensure Caddy or your LB routes 443 to the TURN endpoint). ◦ Open UDP range 50000–60000 and 3478/UDP. ◦ If using the embedded TURN with Caddy fronting, ensure the turn domain points to your VM and Caddy reverse-proxies TCP/TLS to the LiveKit TURN listener. If you want me to: • Generate secure random
API_KEY
and
API_SECRET
and produce ready-to-paste config files personalized to your domain, or • Provide an init_script.sh that automates all of the above so you can run one command on a fresh VM, tell me which and I will produce it.
c
lets sutp vail tmeplete
t
Below are ready-to-paste files you can use on a fresh Ubuntu VM to install Docker, deploy LiveKit with Caddy (automatic TLS), and enable TURN. Replace placeholders (YOUR_DOMAIN, TURN_DOMAIN, API_KEY, API_SECRET) with your values. I’ll also include a one-shot init script you can run as root to perform everything. Files provided: • init_setup.sh — run on the VM (becomes root). Installs Docker, creates /opt/livekit, writes config files, starts docker compose. • /opt/livekit/docker-compose.yaml • /opt/livekit/Caddyfile • /opt/livekit/livekit.yaml 1) Prepare DNS beforehand • A record: YOUR_DOMAIN → YOUR_VM_IP • A record (optional for dedicated TURN TLS): TURN_DOMAIN → YOUR_VM_IP 2) Paste and run this on your VM as root (or run with sudo): • Create the file and run:
Copy code
# as your normal user:
scp init_setup.sh user@YOUR_VM_IP:/home/user/
ssh user@YOUR_VM_IP
sudo bash /home/user/init_setup.sh
3) init_setup.sh (run as root; replace placeholders before running or edit /opt/livekit/* after)
Copy code
#!/usr/bin/env bash
set -e

# --- Edit these values before running or after in /opt/livekit/livekit.yaml ---
YOUR_DOMAIN="livekit.example.com"    # <- replace with your domain
TURN_DOMAIN="turn.livekit.example.com" # <- replace or set same as YOUR_DOMAIN
API_KEY="API_KEY"                     # <- replace with a strong key
API_SECRET="API_SECRET"               # <- replace with a strong secret
# ---------------------------------------------------------------------------

# Update and install prerequisites
apt update && apt upgrade -y
apt install -y ca-certificates curl gnupg lsb-release git ufw

# Install Docker
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

systemctl enable --now docker

# Install docker-compose binary if docker compose subcommand not available
if ! docker compose version >/dev/null 2>&1; then
  curl -SL "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  chmod +x /usr/local/bin/docker-compose
fi

# Create deploy folder
mkdir -p /opt/livekit
cd /opt/livekit

# Write docker-compose.yaml
cat > /opt/livekit/docker-compose.yaml <<'EOF'
version: "3.8"

services:
  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - livekit_net

  livekit:
    image: livekit/livekit-server:latest
    restart: unless-stopped
    environment:
      - LIVEKIT_CONFIG=/livekit/livekit.yaml
    volumes:
      - ./livekit.yaml:/livekit/livekit.yaml:ro
    networks:
      - livekit_net
    ports:
      - "7881:7881"

volumes:
  caddy_data:
  caddy_config:

networks:
  livekit_net:
    driver: bridge
EOF

# Write Caddyfile
cat > /opt/livekit/Caddyfile <<'EOF'
# Main LiveKit signaling & REST
YOUR_DOMAIN {
  reverse_proxy /ws*/* 127.0.0.1:7881
  reverse_proxy /* 127.0.0.1:7880
  log {
    output file /data/caddy/access.log
  }
}

# TURN domain (optional). Caddy will obtain TLS and proxy to LiveKit TURN TLS endpoint.
TURN_DOMAIN {
  reverse_proxy 127.0.0.1:5349
}
EOF

# Write livekit.yaml
cat > /opt/livekit/livekit.yaml <<'EOF'
server:
  rtc_port: 7881
  http_port: 7880
  name: livekit-server

keys:
  - key: "API_KEY"
    secret: "API_SECRET"

turn:
  enabled: true
  # TLS port for TURN. If you want TURN over TLS on 443, set tls_port: 443 and ensure Caddy/LB routes correctly.
  tls_port: 5349
  domain: TURN_DOMAIN
  udp_port: 3478
  relay_udp_min_port: 50000
  relay_udp_max_port: 60000

log:
  level: info
EOF

# Replace placeholders in files with actual values
sed -i "s|YOUR_DOMAIN|${YOUR_DOMAIN}|g" /opt/livekit/Caddyfile
sed -i "s|TURN_DOMAIN|${TURN_DOMAIN}|g" /opt/livekit/Caddyfile
sed -i "s|API_KEY|${API_KEY}|g" /opt/livekit/livekit.yaml
sed -i "s|API_SECRET|${API_SECRET}|g" /opt/livekit/livekit.yaml
sed -i "s|TURN_DOMAIN|${TURN_DOMAIN}|g" /opt/livekit/livekit.yaml

# Set permissions
chown -R root:root /opt/livekit

# Open firewall ports (ufw)
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 7881/tcp
ufw allow 3478/udp
ufw allow 50000:60000/udp
ufw --force enable

# Start services
cd /opt/livekit
docker compose up -d

echo "Deployment started. Replace placeholders in /opt/livekit/* if needed."
echo "Check 'docker ps' and 'docker logs <container>' for status. Client URL: wss://${YOUR_DOMAIN}"
4) After the script runs • Wait a few minutes for Caddy to obtain TLS certs for YOUR_DOMAIN and TURN_DOMAIN. • Verify: ◦ curl -v https://YOUR_DOMAIN ◦ docker ps ◦ docker logs -f <caddy-container-name> ◦ docker logs -f <livekit-container-name> 5) Notes & recommended edits • Replace API_KEY and API_SECRET with generated secure values (example: use openssl rand -hex 16). • If you want TURN TLS on port 443 (recommended for very restrictive networks), set
tls_port: 443
in
livekit.yaml
and ensure the TURN_DOMAIN points to the VM and Caddy proxies 443 traffic to 5349 or route accordingly. The provided Caddyfile proxies TURN_DOMAIN to 127.0.0.1:5349. • If you prefer to generate config locally with the LiveKit generator, you can instead run the
livekit/generate
Docker image on your workstation and copy files into /opt/livekit. • Keep API_SECRET safe; use it only on your backend to mint tokens. If you want, I can: • Generate secure API_KEY/API_SECRET values for you and paste an updated init script, or • Produce a version that sets TURN TLS to 443 now. Which would you like?
c
systemctl start livekit-docker Job for livekit-docker.service failed because the control process exited with error code. See "systemctl status livekit-docker.service" and "journalctl -xeu livekit-docker.service" for details.
t
Thanks — I can help troubleshoot this. Please paste the output of these two commands so I can see the failure details: 1) systemctl status livekit-docker.service
Copy code
sudo systemctl status livekit-docker.service
2) journalctl logs for the unit
Copy code
sudo journalctl -xeu livekit-docker.service --no-pager
If you prefer, paste both outputs together. After I see the logs I’ll point out the error and give the exact fix (likely a config/permission/docker issue) and commands to resolve it.