A Discord music bot is two programs: the bot, which reads slash commands, and an audio server, which does the heavy work. Most hosting trouble comes from treating them as one. You give the pair too little RAM, or you expect YouTube to play from a datacenter the way it plays on your laptop.
This guide explains how the pieces fit, what they really use (we measured Lavalink on one of our servers), what is going on with YouTube in 2026, and how to deploy a music bot that stays online 24/7. We run Bot-Hosting, so the deployment steps use it, but everything before that section applies to any host.
How a Discord music bot plays audio
Your bot keeps one WebSocket open to the Discord gateway. Through it, it receives /play, answers, and asks Discord to join a voice channel. Discord replies with a voice session: a token, an endpoint and a session id for that channel.
The audio itself goes to a different place, a Discord voice server, as Opus packets over UDP. On our fleet we also found that voice needs outbound TCP port 2083 open; it is open on every node.
Fetching a track, decoding it, applying filters and re-encoding it to Opus takes real CPU and memory. That is why most music bots hand the whole job to Lavalink, a standalone Java server built on the lavaplayer library. The bot sends commands to Lavalink over REST, forwards the voice session to it, and gets track events back over a WebSocket. Lavalink connects to the voice server and streams.

One change matters for anyone reusing an old setup. Discord made its end-to-end encryption for calls, DAVE, mandatory on 1 March 2026: since then, clients and apps without DAVE support can no longer take part in calls. Lavalink 4.2.0 was the first release with DAVE support, and its release notes say your client library must be updated too, because the voice state now needs the channel id. An older Lavalink, or an old client library, joins the channel and plays nothing.
How much RAM and CPU a Discord music bot needs
The bot itself is a normal Discord bot. A discord.js or discord.py bot that only sends commands to Lavalink is light. A big feature-rich bot can need more just to start, especially one that compiles its code on the first run: watch its memory graph and size from that.
Lavalink runs on the JVM, and the JVM reserves memory before it does anything useful. We started Lavalink 4.2.2 with the youtube plugin on our dev server, inside a memory-capped cgroup, with the same JVM flags our panel uses: -Xms128M and a heap limit equal to the container limit. Then we read the container’s memory 30 seconds after Lavalink printed “ready”, and again with two players loaded.

Lavalink started even at 256 MB, but with 14 MB of margin and a heap allowed to grow to the whole limit. The first busy evening ends with the kernel killing the JVM. That is why we tell people to plan at least 512 MB for Lavalink alone, and 1 GB if it plays in many servers at once. These players were not connected to a voice channel, so the numbers are a floor: real playback adds buffers per player.
We could not measure CPU per stream for the same reason: without a voice connection, Lavalink does not keep encoding. Watch the CPU graph of your Lavalink deployment during a busy hour, and give it more CPU before you give it more RAM if it stutters.
| Setup | RAM it needs | Plan that fits on Bot-Hosting |
|---|---|---|
| Small bot + a public Lavalink node | the bot only, 256 MB is enough for most | Free (256 MB, 25% of a core) |
| Small bot + your own Lavalink | about 256 to 512 MB + 512 MB | Starter (1 GB, 2 deployments), $2.29 a month |
| Feature-rich bot + your own Lavalink | 512 MB to 1 GB + 512 MB or more | Starter+ (2 GB, 4 deployments), $3.39 a month |
Prices are the ones the pricing page shows for your region, before VAT. The Free plan never sleeps but has to be renewed by hand every 4 days (how renewal works).
If you run Lavalink somewhere else, on a VPS or at home, leave room for the JVM outside the heap: a heap limit around three quarters of the RAM you give it is a safer start than a heap equal to all of it.
The YouTube problem, honestly
Most people want their bot to play YouTube links. In 2026 that is the least reliable part of a music bot, and no host can fix it for you.
Lavaplayer’s own YouTube source is deprecated. YouTube support now comes from a separate plugin, youtube-source, which imitates several YouTube clients and tries them one after another. YouTube keeps changing its players and flags requests it considers automated, and requests from datacenter IPs get flagged a lot.
We tested it on 30 November 2026 from one of our servers in a European datacenter, with Lavalink 4.2.2, youtube-plugin 1.18.2 and its default clients, no OAuth. We searched ten popular songs and tried to play each, three times.

Search worked every time. Playback failed for nine songs out of ten, with This video requires login on the ANDROID_VR and WEB clients and This video is unavailable on WEBEMBEDDED. Your bot shows the song in the queue, then skips it or stays silent, which looks like a bug in your code. It is not. Our two SoundCloud tests failed the same day too, with Did not detect any supported formats, so check your fallback sources as well.
What exists to get around it, and what it costs:
- OAuth with a Google account. The youtube-source README calls it “NOT a silver bullet”, warns that the worst case “could get your account terminated”, and tells you to use a burner account, never your main one.
- A poToken, which the README says only applies to the WEB and WEBEMBEDDED clients and is not a silver bullet either.
- A remote cipher server (yt-cipher), for when YouTube’s signature changes break decoding.
Two more facts belong here. YouTube’s terms of service forbid downloading content and accessing the service by automated means without permission, and a bot that streams YouTube audio does both. And results change from week to week and from one IP to another, so a setup that works today can break tomorrow. We do not ship any workaround enabled, and we will not promise YouTube playback. A host that does is selling a moving target.
What you can rely on more:
- Direct audio links and internet radio streams through Lavalink’s HTTP source. Our MP3 test played. If you have the rights to the files, this is the most stable source there is.
- Bandcamp, Twitch and Vimeo are enabled in our Lavalink config; test them with your own links.
- Spotify and Apple Music links work through the LavaSrc plugin, but read its README: they are marked as “Mirror” sources. LavaSrc reads the track’s metadata, then searches another source, YouTube by default. They inherit the YouTube problem.
Public Lavalink node or your own
You do not have to run Lavalink yourself. Volunteers publish public nodes with a host, port and password anyone can use.
| Public node | Your own Lavalink | |
|---|---|---|
| Cost | Free | 512 MB of RAM or more |
| Fits the Free plan | Yes, the bot alone fits in 256 MB | No, Lavalink needs Starter or above |
| Reliability | Shared with every bot using it; can vanish without notice | Yours; restarts when you restart it |
| YouTube | Usually the most blocked IPs of all | Blocked too, but you choose plugins and settings |
| Privacy | The operator sees every track your users request | Nobody else sees the traffic |
| Version control | Whatever the operator runs, maybe without DAVE | You pick Lavalink 4.2 or newer |
A public node is fine to test your bot on the Free plan. For a bot other people depend on, run your own: the most common “my music bot stopped working” report is a public node that went down or fell behind.
Deploy a Discord music bot 24/7 on Bot-Hosting
This uses two deployments in the same account: a Lavalink service, and your own discord.js bot that sends it commands. The bot below is short on purpose: /play, /skip, /stop and a queue, ready to grow.
1. Deploy Lavalink
Sign in to Bot-Hosting, create a New deployment, choose Service, then Lavalink (“Audio node for Discord music bots”). Give it 512 MB of RAM or more and start it.
You get Lavalink 4.2.2 on Java 21 with the youtube plugin 1.18.2 already configured, the built-in YouTube source turned off, SoundCloud, Bandcamp, Twitch, Vimeo and HTTP enabled, and an application.yml you can edit in the Files tab. Lavalink is ready when the Console prints:
Lavalink is ready to accept connections. Note three values: the host and port from the deployment page or its Network tab, and the password, LAVALINK_SERVER_PASSWORD in the Environment tab. The Lavalink guide covers this step in detail.
2. Create the bot on Discord
- In the Discord Developer Portal, click New Application.
- Under Bot, click Reset Token and copy it.
- Under OAuth2 > URL Generator, tick
botandapplications.commands, grant Connect, Speak and Send Messages, and invite the bot to your server.
The bot below only uses the Guilds and GuildVoiceStates intents, so no privileged intent needs to be turned on.
3. Write the bot
A small discord.js bot with Shoukaku, a Lavalink v4 client. Shoukaku 4.3.0 sends the voice channel id with the voice state, which DAVE requires. package.json:
{
"name": "music-bot",
"private": true,
"main": "index.js",
"engines": { "node": ">=22" },
"dependencies": {
"discord.js": "14.28.1",
"shoukaku": "4.3.0"
}
} index.js:
const { Client, Events, GatewayIntentBits, MessageFlags, SlashCommandBuilder } = require('discord.js');
const { Shoukaku, Connectors } = require('shoukaku');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates] });
const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), [
{
name: 'main',
url: `${process.env.LAVALINK_HOST}:${process.env.LAVALINK_PORT}`,
auth: process.env.LAVALINK_PASSWORD,
secure: process.env.LAVALINK_SECURE === 'true',
},
]);
shoukaku.on('ready', (name) => console.log(`Lavalink node ${name} connected`));
shoukaku.on('error', (name, error) => console.error(`Lavalink node ${name}:`, error));
const queues = new Map(); // guild id -> tracks waiting to play
const commands = [
new SlashCommandBuilder()
.setName('play')
.setDescription('Play a song or add it to the queue')
.addStringOption((o) => o.setName('query').setDescription('A song name or a link').setRequired(true)),
new SlashCommandBuilder().setName('skip').setDescription('Skip the current song'),
new SlashCommandBuilder().setName('stop').setDescription('Stop and leave the voice channel'),
];
client.once(Events.ClientReady, async () => {
await client.application.commands.set(commands);
console.log(`Logged in as ${client.user.tag}`);
});
// Called when a track ends: play the next one, or leave when the queue is empty
async function playNext(guildId) {
const next = queues.get(guildId)?.shift();
if (next) return shoukaku.players.get(guildId)?.playTrack({ track: { encoded: next.encoded } });
queues.delete(guildId);
await shoukaku.leaveVoiceChannel(guildId);
}
function pickTrack(result) {
if (result?.loadType === 'track') return result.data;
if (result?.loadType === 'search') return result.data[0];
if (result?.loadType === 'playlist') return result.data.tracks[0];
return null;
}
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand() || !interaction.inCachedGuild()) return;
const { guildId, commandName } = interaction;
let player = shoukaku.players.get(guildId);
if (commandName === 'skip') {
if (!player) return interaction.reply({ content: 'Nothing is playing.', flags: MessageFlags.Ephemeral });
await player.stopTrack(); // fires 'end', which plays the next track
return interaction.reply('Skipped.');
}
if (commandName === 'stop') {
queues.delete(guildId);
await shoukaku.leaveVoiceChannel(guildId);
return interaction.reply('Stopped.');
}
// /play
const channelId = interaction.member.voice.channelId;
if (!channelId) return interaction.reply({ content: 'Join a voice channel first.', flags: MessageFlags.Ephemeral });
await interaction.deferReply();
const node = shoukaku.getIdealNode();
if (!node) return interaction.editReply('Lavalink is not connected.');
const query = interaction.options.getString('query');
const track = pickTrack(await node.rest.resolve(/^https?:///.test(query) ? query : `ytsearch:${query}`));
if (!track) return interaction.editReply('Nothing found.');
if (player) {
queues.set(guildId, [...(queues.get(guildId) ?? []), track]);
return interaction.editReply(`Queued: ${track.info.title}`);
}
player = await shoukaku.joinVoiceChannel({ guildId, channelId, shardId: interaction.guild.shardId });
player.on('end', ({ reason }) => {
if (reason !== 'replaced') playNext(guildId);
});
player.on('exception', ({ exception }) => console.error(`Track failed: ${exception?.message}`));
await player.playTrack({ track: { encoded: track.encoded } });
return interaction.editReply(`Playing: ${track.info.title}`);
});
client.login(process.env.DISCORD_TOKEN); A link is played as it is; anything else is searched on YouTube with ytsearch:. Given the YouTube problem above, test with a direct MP3 link first: if that plays, the bot and Lavalink are wired correctly. To search SoundCloud instead, change the prefix to scsearch:.
4. Deploy the bot
Create a second New deployment: Application, then Node.js. As the Source, pick GitHub if the two files are in a repository, or Archive with a .zip of them, without node_modules. The entry file defaults to index.js, and dependencies are installed from package.json at each start.
In the Environment tab, add:
| Variable | Value |
|---|---|
DISCORD_TOKEN | the token from step 2 (tick Secret) |
LAVALINK_HOST, LAVALINK_PORT | the host and port from step 1 |
LAVALINK_PASSWORD | the password from step 1 (secret) |
LAVALINK_SECURE | false for a Lavalink hosted here |
256 MB of RAM is enough for this bot. To use a public node instead, put its host, port and password in the same three variables, and set LAVALINK_SECURE to true if the operator says the node uses TLS. The Console prints Lavalink node main connected and Logged in as ... when both connections are up.
5. Play something
Join a voice channel and type /play with a song name or a link. /skip and /stop do what they say. When something does not play, look at the Lavalink deployment’s console first: that is where the real error is.
From there, the bot is yours to grow: a /queue command that lists the queues map, a loop mode, volume and filters through Shoukaku’s setGlobalVolume and setFilters. Writing in Python? wavelink connects to the same Lavalink with the same three values.
More on the platform side, from plans to regions: Discord music bot hosting.
When the music bot does not play
- The track is queued, then skipped, and Lavalink logs
This video requires login. That is the YouTube block described above, not your code. Try a direct link or another source to confirm. - The bot joins the channel and stays silent, with no error. Check the versions: Lavalink 4.2 or newer, and a client library recent enough for DAVE. Since 1 March 2026, an old pair cannot take part in calls.
Connection refusedor a timeout when the bot connects to Lavalink. Wrong host or port, or Lavalink is not started. Copy the values again from the Lavalink deployment.401orUnauthorizedfrom Lavalink. The password does not matchLAVALINK_SERVER_PASSWORD.- Lavalink restarts by itself during busy hours. It ran out of memory. Give it more RAM, and check the 256 MB row in the chart above.
- Voice never connects on your own server or VPS. Make sure outbound UDP and TCP 2083 are allowed by your firewall.
Sources
Checked on 30 November 2026:
- Discord: Bringing DAVE to all Discord platforms, 2 September 2025, for the 1 March 2026 requirement.
- Lavalink: 4.2.0 release notes (first release with DAVE) and the Lavalink repository (Java 17 or newer required).
- youtube-source README, for the plugin setup, the OAuth warnings, poToken and remote cipher.
- LavaSrc README, for which sources are “Mirror” and which play directly.
- Shoukaku 4.3.0 source, for the channel id it sends with the voice state.
- YouTube Terms of Service, section “Permissions and restrictions” (effective 9 January 2026).
- Our own measurements, 30 November 2026: Lavalink 4.2.2, youtube-plugin 1.18.2, Temurin 21, on our dev server.
Lavalink and its plugins move fast. If a version or behavior here is out of date, the project’s release notes are the reference.