Lavalink Documentation

Everything you need to know about using Lavalink

Introduction

Lavalink is a standalone audio sending node based on Lavaplayer and Koe. It allows for sending audio without it ever reaching any of your Discord bot shards.

With Lavalink, you can:

  • Stream audio from various sources like YouTube, SoundCloud, Bandcamp, and more
  • Use minimal CPU/memory resources
  • Control volume, seeking, and other audio features
  • Distribute your audio load across multiple servers
  • Enjoy enhanced stability for your Discord music bots

Requirements

To run Lavalink, you'll need:

  • Java 17 LTS or newer (OpenJDK or Zulu JDK recommended)
  • A server or VPS to host Lavalink (not compatible with serverless platforms like Vercel)
  • Open ports for the Lavalink server (default: 2333)
  • A Discord bot that uses a Lavalink client library

Configuration

Lavalink uses an application.yml file for configuration. Here's a basic example:

server:
  port: 2333
  address: 0.0.0.0
lavalink:
  server:
    password: "youshallnotpass"
    sources:
      youtube: true
      bandcamp: true
      soundcloud: true
      twitch: true
      vimeo: true
      http: true
      local: false
    bufferDurationMs: 400
    youtubePlaylistLoadLimit: 6
    playerUpdateInterval: 5
    youtubeSearchEnabled: true
    soundcloudSearchEnabled: true
    gc-warnings: true

metrics:
  prometheus:
    enabled: false
    endpoint: /metrics

sentry:
  dsn: ""
  environment: ""

The most important settings to change are:

  • server.port: The port Lavalink will run on
  • lavalink.server.password: A secure password for client authentication
  • server.address: The IP address to bind to (0.0.0.0 for all interfaces)

Client Libraries

To connect your Discord bot to Lavalink, you'll need a client library. Here are some popular options:

JavaScript/TypeScript

  • Shoukaku
  • Erela.js
  • lavacord

Java

  • Lavalink-Client
  • LavaClient
  • JDA-Lavalink

Python

  • Wavelink
  • Lavapy
  • Pomice

C#/.NET

  • Victoria
  • Lavalink4NET
  • DSharpPlus.Lavalink

REST API

Lavalink provides a REST API for managing players and tracks. All endpoints require authentication using the password specified in the configuration.

Common endpoints include:

  • GET /loadtracks - Load tracks from a URL
  • GET /decodetrack - Decode a track
  • GET /decodetracks - Decode multiple tracks
  • GET /version - Get version information
  • GET /stats - Get server statistics

For detailed API documentation, visit theLavalink Protocol documentation.

Troubleshooting

Connection Issues

If your bot can't connect to Lavalink, check:

  • Ensure the server is running and the port is open
  • Verify the password matches in both client and server
  • Check that your client library is configured correctly

Audio Not Playing

If audio isn't playing:

  • Check if the source is supported (YouTube, SoundCloud, etc.)
  • Verify the bot has permission to join and speak in voice channels
  • Look for errors in the Lavalink console output

High CPU Usage

If Lavalink is using too much CPU:

  • Consider distributing load across multiple Lavalink nodes
  • Check if Java has enough available memory
  • Consider upgrading your server resources