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: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 a400 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.- Option 1 — Update the Lavalink client library (recommended)
- Option 2 — Use a Lavalink server version compatible with your client
Updating the client library is the preferred approach because it keeps your server on the latest stable release.
Identify your Lavalink client library
Common Lavalink client libraries for Discord bots include
lavalink-client, erela.js, shoukaku, poru, and lavaclient. Check your package.json or requirements.txt to find which one you’re using.Find a v4-compatible version
Look up your library on npm or PyPI and identify the version that adds Lavalink v4 support. Most popular libraries released a major version bump when they added v4 compatibility — check the library’s changelog or README for guidance.
Update your connection code
Lavalink v4-compatible clients often have slightly different connection option signatures. Consult your library’s migration guide for any breaking changes. A typical Lavalink v4 connection configuration looks like:
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:Lavalink server must listen on port 80
Lavalink server must listen on port 80
When hosting your Lavalink server as an application on Virtus Cloud, configure it to listen on port 80 (the platform’s default HTTP port). Set this in your Lavalink
application.yml:application.yml
Your bot must connect using port 443 with secure: true
Your bot must connect using port 443 with secure: true
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.If you continue to experience Lavalink connection errors after following these steps, contact the Virtus Cloud support team.