discord-hosting.cloud
20% Off First MonthSee prices

Guide

Music bots with Lavalink: setup and memory

Playing audio is heavy work: decoding, re-encoding and sending voice packets. Lavalink is a separate Java audio server that does this for your bot, so the bot itself stays small.

Updated 7 min read

How it fits together

  • Your bot handles commands and tells Lavalink what to play.
  • Lavalink fetches and encodes the audio and sends it to Discord voice.
  • Run Lavalink as its own server (it needs Java 17 or newer and its own RAM), and point the bot at its address and port.
application.yml
server:
  port: 2333          # use the port the panel assigned
  address: 0.0.0.0
lavalink:
  server:
    password: "change-me-to-a-long-random-string"
    sources:
      http: true
      local: false
logging:
  level:
    root: INFO

Source plugins (for example for YouTube) are separate downloads that change often. Respect the terms of the services you stream from.

Connect from the bot

Use a Lavalink client library: for discord.js, lavalink-client or Shoukaku; for Python, wavelink or lavalink.py. Each takes the host, port and password from your config.

.env
LAVALINK_HOST=203.0.113.10
LAVALINK_PORT=2333
LAVALINK_PASSWORD=change-me-to-a-long-random-string

Memory

Lavalink alone usually wants 300 to 600 MB to start, more with many players at once. The bot itself stays near its normal size. Put Lavalink on a plan with room for it (4 GB covers most small and medium music bots) and use the RAM calculator for the bot.