Lavalink is a standalone audio server for Discord bots. Instead of your bot downloading and encoding audio directly, Lavalink handles all audio processing separately, reducing bot CPU usage and improving stability.
Why Use Lavalink?
- Lower bot CPU usage: Audio processing runs on Lavalink, not your bot
- Better audio quality: Professional audio pipeline
- Scalability: One Lavalink server can serve multiple bots
- Stability: Bot crashes do not interrupt playback (Lavalink keeps the audio stream)
Requirements
- Java 17 or newer
- VPS with at least 512 MB RAM (1 GB recommended)
- Your Discord bot (Node.js or Python)
Installation
1. Install Java 17+
sudo apt update
sudo apt install openjdk-17-jre-headless
2. Download Lavalink
mkdir lavalink && cd lavalink
wget https://github.com/lavalink-devs/Lavalink/releases/latest/download/Lavalink.jar
3. Create application.yml
server:
port: 2333
address: 0.0.0.0
lavalink:
server:
password: "your-secure-password"
sources:
youtube: true
soundcloud: true
bandcamp: true
twitch: true
http: true
local: false
4. Run Lavalink
java -jar Lavalink.jar
For production, use a systemd service or PM2:
pm2 start "java -jar Lavalink.jar" --name lavalink
Connecting Your Bot
Node.js (discord.js + Shoukaku/Erela.js)
Popular Lavalink clients for discord.js:
- Shoukaku, Lightweight, modern
- Kazagumo, Built on Shoukaku with more features
- Erela.js, Older but widely documented
Python (discord.py + Wavelink/Pomice)
Popular Lavalink clients for Python:
- Wavelink, Modern async client
- Pomice, Alternative with good documentation
VPS Requirements
| Setup | RAM | CPU |
|---|---|---|
| Lavalink only | 512 MB | 1 core |
| Lavalink + bot | 1 GB | 1 core |
| Multiple bots | 2 GB | 2 cores |
FAQ
Is Lavalink free? Yes. It is open source.
Does Lavalink need its own VPS? Not necessarily. It can run on the same VPS as your bot.
Can Lavalink play YouTube? Yes, with the YouTube source enabled. Note that YouTube may restrict access, plugins like LavaSrc can help.
Related: Discord bot hosting guide, Best VPS for Discord bots, discord.py alternatives