---
title: "Deploy LiveKit"
description: "Realtime video, audio and voice-agent server with recording to a bucket."
category: "Other"
url: https://railway.com/deploy/livekit-webrtc-server
---

# Deploy LiveKit

Realtime video, audio and voice-agent server with recording to a bucket.

**[Deploy LiveKit on Railway](https://railway.com/template/livekit-webrtc-server)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/livekit-webrtc-server/manifest.json

- **Creator:** blueorange
- **Category:** Other

## Template content

### Egress https://cdn.simpleicons.org/livekit/white.svg

- **Source:** https://github.com/gridalpha/livekit-railway
- **Health check:** /

### LiveKit https://cdn.simpleicons.org/livekit/white.svg

- **Source:** https://github.com/gridalpha/livekit-railway
- **Health check:** /
- **Public domain:** Yes

### Redis https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/redis.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Buckets

- **livekit-egress**

## Documentation

# Deploy and Host LiveKit on Railway

![LiveKit logo](https://cdn.simpleicons.org/livekit/white.svg)

LiveKit is an open source **WebRTC media server** that moves live audio, video and data between browsers, mobile apps and programs in real time. It's a Selective Forwarding Unit written in Go: each participant sends one stream up and LiveKit forwards it to everyone else, so rooms stay light on the client as they grow. LiveKit is Apache-2.0, has about 22,000 GitHub stars, and powers video calls, live classes, telehealth, robotics and **realtime AI voice agents** built with the LiveKit Agents framework. This template deploys the full production shape on Railway: the media server, Redis for room routing, the LiveKit Egress worker for recordings and RTMP streaming, and a Railway object storage bucket for the files. LiveKit Cloud's paid plans start at $50/month. Self-hosting on Railway costs roughly $10–40/month plus bandwidth, with no per-minute charges.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **LiveKit** | `livekit/livekit-server` with a Railway wrapper. Signalling and the API over HTTPS on port `7880`, and WebRTC media over a TCP proxy on port `7881`. |
| **Redis** | Redis 8.2 with a password and a volume. Shared room state, and the job queue Egress listens on. |
| **Egress** | `livekit/egress`, private. Records rooms or single tracks and streams them out over RTMP. |
| **livekit-egress bucket** | A Railway object storage bucket. Egress uploads finished recordings here. |

A 24-character API key and a 64-character API secret are generated at deploy time. Egress references them from the LiveKit service, so the two always match.

---

## About Hosting LiveKit on Railway

WebRTC usually runs over UDP. **Railway doesn't route inbound UDP**, so this template runs LiveKit in TCP-only mode: browsers connect to the public HTTPS domain for signalling, and media flows over ICE/TCP through a Railway TCP proxy. The wrapper's entrypoint works out the proxy's public address and port on every boot and tells LiveKit to advertise them, so clients get candidates that actually connect.

**What TCP-only means.** Calls work in every modern browser and SDK, and TCP often gets through corporate firewalls that block UDP. On lossy mobile networks, TCP can add delay compared with UDP, so test with your real users. For very large or latency-critical events, a host with UDP is the better fit.

**Recording and streaming.** Egress joins a room like a hidden participant, mixes or captures tracks, and writes MP4 or other files to the bucket, or pushes the output to an RTMP endpoint such as YouTube. Without a bucket, recordings would vanish when the container restarts; this template wires the bucket in for you.

**Voice AI agents.** LiveKit Agents (Python or Node.js) connects to this server with the same API key and secret. Your agent joins a room, listens to the user, sends audio to speech-to-text, a language model and text-to-speech, and talks back with low latency. The agents run as your own separate service.

**Tokens, not passwords.** Clients join rooms with short-lived access tokens that your backend signs with the API secret. Never ship the secret to a browser.

Typical cost: **~$10–40/month** on Railway for the four pieces at small scale, plus $0.05 per GB of egress bandwidth. Media is the big variable: a 720p video stream is roughly 1–2 Mbps per subscriber. LiveKit Cloud is free up to 5,000 WebRTC minutes, then $50/month for Ship and $500/month for Scale.

---

## Deploy LiveKit in Under 10 Minutes

1. Click **Deploy on Railway**. LiveKit, Egress, Redis and the bucket are created and wired together.
2. Open the **LiveKit** service and copy `LIVEKIT_API_KEY` and `LIVEKIT_API_SECRET` from **Variables**.
3. Note the public domain; your client URL is `wss://` plus that domain.
4. In your backend, create an access token with a LiveKit server SDK, using the key and secret.
5. Join a room from the LiveKit web SDK, the Meet example app or the Agents playground, and check that video flows.

To record, call the Egress API from your backend; finished files appear in the bucket.

---

## Common Use Cases

- **Video calls in your app.** Add rooms with screen sharing, chat and data messages using LiveKit's SDKs.
- **Voice AI agents.** Run LiveKit Agents against your own server for phone-like conversations with an LLM.
- **Live classes and webinars.** A few presenters publish, many viewers subscribe.
- **Telehealth and support.** Keep calls on infrastructure you control.
- **Recording and archives.** Save meetings or lessons as MP4 files in your bucket.
- **Restreaming.** Push a room to YouTube, Twitch or any RTMP destination with Egress.
- **Multiplayer and watch parties.** Sync game state or playback over data channels alongside voice chat.
- **Robotics and IoT.** Stream camera feeds and send control messages with low latency.

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `LIVEKIT_API_KEY` | 🔐 Auto-generated | Key clients' tokens are signed with. Egress references it. |
| `LIVEKIT_API_SECRET` | 🔐 Auto-generated | 64-character signing secret. Keep it server-side. |
| `PORT` | ✅ Set | `7880`, HTTP and WebSocket signalling. |
| `LIVEKIT_REDIS_*` | ✅ Auto-injected | Redis host, port, user and password from the Redis service. |
| `LIVEKIT_LOG_LEVEL` | ✅ Set | `info`. Use `debug` when troubleshooting. |
| `LIVEKIT_WS_URL` | ✅ Auto-set | On Egress: `wss://` plus the LiveKit domain. |
| `EGRESS_REDIS_*` | ✅ Auto-injected | The same Redis the media server uses. |
| `EGRESS_S3_*` | ✅ Auto-injected | Bucket name, endpoint, region and keys from the Railway bucket. |
| `RAILWAY_DOCKERFILE_PATH` | ✅ Set | `server/Dockerfile` or `egress/Dockerfile` in the wrapper repo. |

**Optional server settings.** Add `LIVEKIT_WEBHOOK_URLS` to receive room events in your backend, and `LIVEKIT_ROOM_EMPTY_TIMEOUT` to control how long empty rooms stay open.

**Keep the TCP proxy.** Media depends on the TCP proxy on port 7881. If you delete and recreate it, redeploy LiveKit so it advertises the new port.

---

## LiveKit on Railway vs. Alternatives

| | LiveKit on Railway | LiveKit Cloud | Agora | Jitsi Meet |
|---|---|---|---|---|
| **Monthly cost** | ~$10–40 plus bandwidth | Free tier, then $50+ | Per minute | Self-host costs |
| **Self-hosted** | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
| **SDKs for web, iOS, Android** | ✅ Yes | ✅ Yes | ✅ Yes | ⚠️ Mainly a meeting app |
| **Voice AI agents framework** | ✅ LiveKit Agents | ✅ LiveKit Agents | ⚠️ Separate products | ❌ No |
| **Recording and RTMP out** | ✅ Egress and bucket | ✅ Yes | ✅ Yes | ⚠️ Add-on |
| **UDP media** | ❌ TCP only on Railway | ✅ Yes | ✅ Yes | ✅ Yes |
| **License** | ✅ Apache-2.0 | ⚠️ Hosted service | ❌ Proprietary | ✅ Apache-2.0 |

---

## Dependencies for LiveKit Hosting

- Railway account. Pro is recommended for Egress, which needs more CPU and RAM while recording.
- A backend that signs access tokens with a LiveKit server SDK.
- Optional: LiveKit Agents for voice AI, and an RTMP destination for streaming.

### Deployment Dependencies

- [LiveKit on GitHub](https://github.com/livekit/livekit): server source and releases
- [LiveKit Egress](https://github.com/livekit/egress): recording and streaming
- [livekit-railway](https://github.com/gridalpha/livekit-railway): the Railway wrappers used here
- [LiveKit docs](https://docs.livekit.io): SDKs, tokens and Agents

### Implementation Details

Both services build thin layers over the official `livekit/livekit-server` and `livekit/egress` images on their `latest` tags, so a redeploy picks up new upstream releases. The server entrypoint generates the config file at boot, bridges the TCP proxy port into the container with `socat`, and turns on `force_tcp` so clients aren't offered UDP candidates that can't work. Egress builds its YAML config from separate variables.

Redis is what lets LiveKit grow past one node. Each node registers in Redis and each room is assigned to one node, so a single room always lives on one server while different rooms can be spread across several.

---

## Frequently Asked Questions

**What is LiveKit?**
An Apache-2.0 WebRTC server (SFU) with SDKs for web and mobile, used for video calls, live streaming and realtime AI voice agents.

**Does it work without UDP?**
Yes. Media runs over ICE/TCP through Railway's TCP proxy. It works in all modern browsers, though UDP can be smoother on poor mobile networks.

**How much does it cost compared with LiveKit Cloud?**
About $10–40/month on Railway plus bandwidth at $0.05 per GB, with no per-minute fees. LiveKit Cloud is free to 5,000 WebRTC minutes, then $50/month.

**Can I run voice AI agents with it?**
Yes. Point LiveKit Agents at your `wss://` URL with the API key and secret, and run the agent as its own service.

**Where do recordings go?**
To the Railway bucket created with the template. Egress uploads each finished file there.

**How do clients join a room?**
Your backend signs an access token with the API key and secret, and the client connects to the `wss://` URL with that token.

---

## Why Deploy and Host LiveKit on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying LiveKit on Railway, you get a complete realtime media stack with routing, recording and storage on infrastructure you control, at a predictable monthly cost.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/livekit-webrtc-server
