Skip to main content
If your music bot uses Lavalink for audio playback and you’re seeing WebSocket errors when it tries to connect to your Lavalink server, the root cause is almost always a version mismatch between your Lavalink server and the Lavalink client library your bot uses. Starting with Lavalink v4, the server switched from a WebSocket-first protocol to a fully REST-based API — older client libraries that expect a direct WebSocket connection will fail immediately with a 400 response and a 1006 close code. This guide walks you through the correct fix and includes the essential port configuration steps required to make Lavalink work on Virtus Cloud.

When Does It Occur?

You’ll see one or both of the following errors in your application logs when your bot attempts to connect to a Lavalink server:
Error: Unexpected server response: 400
Error: WebSocket closed abnormally with code 1006.
The errors appear at startup or whenever your bot tries to establish the audio session, and the connection never completes successfully.

Why Does It Occur?

Lavalink v4 (and later) uses a fully REST-based architecture. The client no longer initiates a direct WebSocket upgrade from the bot’s side in the same way as earlier versions. If your Lavalink client library was written for Lavalink v3 or earlier, it tries to open a WebSocket connection that the v4 server doesn’t accept — resulting in a 400 Bad Request response, which causes the WebSocket handshake to fail with close code 1006. In short: your Lavalink server version and your Lavalink client library version must be compatible with each other.

How to Fix It

You have two options: update your client library to one that supports your server version, or downgrade your server to match your existing client.

Required Port Configuration for Virtus Cloud

Regardless of which Lavalink version you use, you must follow these Virtus Cloud-specific port rules for Lavalink to work correctly:
Virtus Cloud terminates TLS at the edge and forwards traffic internally over HTTP. Your bot must connect to the Lavalink server using port 443 (HTTPS/WSS) with the secure: true option. The platform handles the SSL handshake, so your Lavalink server doesn’t need an SSL certificate.
nodes: [
  {
    host: 'your-lavalink-subdomain.virtusapp.cloud',
    port: 443,
    authorization: 'your-password',
    secure: true,
  }
]
After resolving the version mismatch and configuring the correct ports, restart both your Lavalink server and your bot. The connection should complete successfully and your music commands should work as expected.
If you continue to experience Lavalink connection errors after following these steps, contact the Virtus Cloud support team.