i want self-hosted the livekit in my own machine p...
# ask-ai
b
i want self-hosted the livekit in my own machine please guide me step by step
t
Thanks for reaching out, Vishnu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking for a step-by-step guide to self-host LiveKit on your machine — below is a concise walkthrough to get you running locally (development), plus next steps for production. 1) Install LiveKit server • macOS (Homebrew):
Copy code
brew update && brew install livekit
• Linux:
Copy code
curl -sSL https://get.livekit.io | bash
• Windows: download the latest release from the LiveKit GitHub releases page and install manually. 2) Start in development mode • Run:
Copy code
livekit-server --dev
• Dev credentials used by the server: ◦ API Key: devkey ◦ API Secret: secret • This is for testing only. 3) Allow network access (optional) • To accept connections from other devices on your LAN:
Copy code
livekit-server --dev --bind 0.0.0.0
• Connect clients to ws//<your machine ip>7880 or wss if you enable TLS. 4) Verify the server is running • Default address: 127.0.0.1:7880 (or your machine IP:7880 when binding 0.0.0.0). • Test with a simple frontend app or the LiveKit Connection Tester. 5) Generate tokens for clients • Clients must use auth tokens to join rooms. Use a server SDK to generate tokens (Node.js example):
Copy code
npm install livekit-server-sdk
• Create an endpoint that uses your API key/secret to create join tokens for rooms and return them to clients. 6) Quick tips for production • Use Docker/VMs/Kubernetes for deployments. • Configure a domain and TLS (Let’s Encrypt with Caddy is a common option). • Consider running Ingress (RTMP/WHIP input) and Egress services if you need recording/streaming features. • Follow deployment guides when scaling beyond a single dev machine. If you’d like, I can: • Provide a minimal token-generation code snippet in Node, Python, or Go. • Give a Docker Compose or Kubernetes example for production. Which of those would you like next? Sources: Running LiveKit locally | LiveKit docs | Generating tokens | LiveKit docs | Running LiveKit on AWS | Deploy to a VM | LiveKit docs | Self-hosting the Ingress Service | LiveKit docs
b
Give a Docker Compose
t
Thanks — below is a ready-to-use Docker Compose setup for self-hosting LiveKit plus Redis. It includes a sample
livekit.yaml
mount, API key/secret via env, and exposed ports for WebSocket/WebRTC. docker-compose.yml
Copy code
version: "3.7"

services:
  livekit:
    image: livekit/livekit-server:latest
    ports:
      - "7880:7880"       # HTTP / WebSocket
      - "7881:7881"       # WebRTC TCP
      - "7882:7882/udp"   # WebRTC UDP
    environment:
      - LIVEKIT_KEYS=devkey:secret
      - LIVEKIT_REDIS_URL=redis://redis:6379/0
    volumes:
      - ./livekit.yaml:/livekit.yaml:ro
    command:
      - --config=/livekit.yaml
      - --node-ip=auto
    depends_on:
      - redis
    restart: unless-stopped

  redis:
    image: redis:7
    restart: unless-stopped
Sample minimal livekit.yaml (place next to docker-compose.yml)
Copy code
keys:
  - key: "devkey"
    secret: "secret"

logging:
  level: info

network:
  node_ip: "auto"
Instructions • Save both files in one directory. • Replace
devkey:secret
with your chosen API key and secret for production. • Run:
docker compose up -d
• By default LiveKit will be reachable at http://localhost:7880 (or ws//<host ip>7880 when binding to network). • Create token endpoints in your app using the same API key/secret so clients can join rooms. If you want, I can: • Provide a Node.js token-generation snippet, • Add TLS (Caddy) and a reverse proxy example, • Convert this to a production-ready Compose (Turn config, persistent volumes, healthchecks). Which would you like? Sources: Self-hosted SIP server | LiveKit docs | Deploying LiveKit | LiveKit docs | Deploy to a VM | LiveKit docs
b
• Consider running Ingress (RTMP/WHIP input) and Egress services if you need recording/streaming features. i want this features too
t
Thanks — below is a ready-to-run Docker Compose setup that includes LiveKit server, Ingress (RTMP/WHIP), Egress, and Redis. Save this as
docker-compose.yml
and place the sample
livekit.yaml
and `ingress.yaml`/`egress.yaml` shown after it in the same folder. Replace the API keys, secrets, domain, and cert paths before running. docker-compose.yml
Copy code
version: "3.7"

services:
  redis:
    image: redis:7-alpine
    command: ["redis-server", "--bind", "0.0.0.0"]
    restart: unless-stopped

  livekit:
    image: livekit/livekit-server:latest
    ports:
      - "7880:7880"       # HTTP / WebSocket
      - "7881:7881"       # WebRTC TCP
      - "7882:7882/udp"   # WebRTC UDP
      - "3478:3478/udp"   # STUN/TURN (if used)
      - "50000-60000:50000-60000/udp" # RTP ports
    environment:
      - LIVEKIT_KEYS=your-api-key:your-api-secret
      - LIVEKIT_REDIS_URL=redis://redis:6379/0
    volumes:
      - ./livekit.yaml:/livekit.yaml:ro
      - ./certs:/certs:ro   # optional TLS certs for production
    command:
      - --config=/livekit.yaml
      - --node-ip=auto
    depends_on:
      - redis
    restart: unless-stopped

  ingress:
    image: livekit/ingress:latest
    cap_add:
      - SYS_ADMIN
    ports:
      - "1935:1935"     # RTMP
      - "7885:7885/udp" # WHIP/DATA UDP (if configured)
      - "8080:8080"     # WHIP/HTTP (optional)
    environment:
      - INGRESS_API_KEY=your-api-key
      - INGRESS_API_SECRET=your-api-secret
      - INGRESS_WS_URL=ws://livekit:7880
      - INGRESS_REDIS_URL=redis://redis:6379/0
    volumes:
      - ./ingress.yaml:/ingress.yaml:ro
    depends_on:
      - livekit
      - redis
    restart: unless-stopped

  egress:
    image: livekit/egress:latest
    cap_add:
      - SYS_ADMIN
    ports:
      - "7980:7980"   # optional template/HTTP port
    environment:
      - EGRESS_API_KEY=your-api-key
      - EGRESS_API_SECRET=your-api-secret
      - EGRESS_WS_URL=ws://livekit:7880
      - EGRESS_REDIS_URL=redis://redis:6379/0
    volumes:
      - ./egress.yaml:/egress.yaml:ro
      - ./egress-output:/output
    depends_on:
      - livekit
      - redis
    restart: unless-stopped
Sample livekit.yaml
Copy code
keys:
  - key: "your-api-key"
    secret: "your-api-secret"

logging:
  level: info

network:
  node_ip: "auto"

rtc:
  udp_port: 7882
  tcp_port: 7881
Sample ingress.yaml (minimal)
Copy code
api_key: "your-api-key"
api_secret: "your-api-secret"
ws_url: "ws://livekit:7880"
redis:
  address: "redis:6379"
rtmp:
  port: 1935
whip:
  http_port: 8080
  udp_port: 7885
logging:
  level: info
rtc_config:
  udp_port: 7885
  use_external_ip: false
Sample egress.yaml (minimal)
Copy code
api_key: "your-api-key"
api_secret: "your-api-secret"
ws_url: "ws://livekit:7880"
redis:
  address: "redis:6379"
template_port: 7980
enable_chrome_sandbox: true
log_level: info
output:
  dir: /output
Quick start 1. Edit files: replace
your-api-key:your-api-secret
, domain, and certs as needed. 2. Create
certs/
if using TLS and place `fullchain.pem`/`privkey.pem` there. 3. Run: ◦ docker compose up -d 1. Check logs: ◦ docker compose logs -f How to use • Ingress (RTMP): create an ingress via the CreateIngress API to get stream key+URL, then push from OBS to rtmp(s)://<your-host>/live with that key. • WHIP: use the ingress WHIP endpoint returned by CreateIngress for browser-based sources. • Egress: use the Egress API or
lk egress
CLI to start room-composite, track egress, or stream to RTMP/S3. Notes and recommendations • Egress uses Chrome for composites; keep
cap_add: SYS_ADMIN
and consider the Chrome seccomp profile for sandboxing. • Ingress/Egress are CPU/memory intensive; allocate sufficient resources. • Open required ports in your firewall (1935, 7880-7882, RTP range, 3478, etc.). • For production, front with TLS (Caddy/Nginx) and persistent storage for recordings. Would you like a Node.js token-generation snippet or an example CreateIngress/CreateEgress request next? Sources: Self-hosting the Ingress Service | LiveKit docs | Universal Egress | Self-hosting the Egress Service | LiveKit docs | Egress API | LiveKit docs | Stream import | LiveKit docs