Cannot get discord bot to join voice channel. 4006 ERROR!

I haven't been able to resolve it myself for hours and I feel like it's not the code but possibly discord's end. I've been looking for support so I hope this is the right place.
Shard ID None WebSocket closed with 4006
Shard ID None WebSocket closed with 4006
Code:
import discord
from discord.ext import commands
from config import TOKEN


VOICE_CHANNEL_ID = [a valid one]
AUDIO_FILE = "vineboom.mp3"

intents = discord.Intents.default()
intents.voice_states = True

bot = commands.Bot(command_prefix="`", intents=intents)

@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
channel = bot.get_channel(VOICE_CHANNEL_ID)
if channel:
vc = await channel.connect()
vc.play(discord.FFmpegPCMAudio(AUDIO_FILE))

bot.run(TOKEN)
import discord
from discord.ext import commands
from config import TOKEN


VOICE_CHANNEL_ID = [a valid one]
AUDIO_FILE = "vineboom.mp3"

intents = discord.Intents.default()
intents.voice_states = True

bot = commands.Bot(command_prefix="`", intents=intents)

@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
channel = bot.get_channel(VOICE_CHANNEL_ID)
if channel:
vc = await channel.connect()
vc.play(discord.FFmpegPCMAudio(AUDIO_FILE))

bot.run(TOKEN)
Steps taken so far to resolve problem: Libraries updated: Discord_py-2.5.2 PyNaCl-1.5.0 aiohttp-3.12.13 Fresh install of python 3.13.5 Restarting code, restarting pc, restarting internet. Kicking and re inviting bot, changing bot token. Snippet of the log:
2025-06-14 19:09:30 INFO discord.voice_state Starting voice handshake... (connection attempt 1)
2025-06-14 19:09:30 INFO discord.voice_state Voice handshake complete. Endpoint found: c-iad08-a5e02106.discord.media
2025-06-14 19:09:30 ERROR discord.voice_state Failed to connect to voice... Retrying in 1.0s...
Traceback (most recent call last):
File "C:\Python313\Lib\site-packages\discord\voice_state.py", line 413, in _inner_connect
await self._handshake_websocket()
File "C:\Python313\Lib\site-packages\discord\voice_state.py", line 583, in _handshake_websocket
await self.ws.poll_event()
File "C:\Python313\Lib\site-packages\discord\gateway.py", line 1039, in poll_event
raise ConnectionClosed(self.ws, shard_id=None, code=self._close_code)
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 4006
2025-06-14 19:09:30 INFO discord.voice_state Starting voice handshake... (connection attempt 1)
2025-06-14 19:09:30 INFO discord.voice_state Voice handshake complete. Endpoint found: c-iad08-a5e02106.discord.media
2025-06-14 19:09:30 ERROR discord.voice_state Failed to connect to voice... Retrying in 1.0s...
Traceback (most recent call last):
File "C:\Python313\Lib\site-packages\discord\voice_state.py", line 413, in _inner_connect
await self._handshake_websocket()
File "C:\Python313\Lib\site-packages\discord\voice_state.py", line 583, in _handshake_websocket
await self.ws.poll_event()
File "C:\Python313\Lib\site-packages\discord\gateway.py", line 1039, in poll_event
raise ConnectionClosed(self.ws, shard_id=None, code=self._close_code)
discord.errors.ConnectionClosed: Shard ID None WebSocket closed with 4006
3 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Birbatiel
BirbatielOP3mo ago
darn okay.

Did you find this page helpful?