> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.squarecloud.app/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Lavalink closed abnormally (1006): how to fix

## What this error means

When your music bot tries to connect to its Lavalink server hosted on Square Cloud, the connection drops immediately:

```
Error: Unexpected server response: 400
Error: WebSocket closed abnormally with code 1006.
```

## Why it happens

This is almost always a **version mismatch between Lavalink and the client (wrapper)** your bot uses. For example, **Lavalink v4 is fully REST-based and is not compatible with a v3 client** — the handshake fails and the WebSocket closes with code 1006.

## How to fix it

**1. Match the versions.** Update your Lavalink client to the latest release, or run a Lavalink version that's compatible with your current client. Check your wrapper's documentation for the supported Lavalink major version.

**2. Configure the ports correctly on Square Cloud:**

* Open the Lavalink server on port **80**.
* Connect to it using port **443** with the `secure: true` option enabled in your client.

**3. Restart both** the Lavalink application and your bot.

## Related

Hosting the bot itself? See [How to host a Discord bot](https://help.squarecloud.app/en-us/article/how-to-host-a-discord-bot-e2udcn/). To keep both the bot and the Lavalink server online without interruptions, see [How to keep bots online 24/7](https://help.squarecloud.app/en-us/article/how-to-keep-bots-online-247-1j8fio/). Building a music bot with Lavalink from scratch? See [How to host a music bot with Lavalink](https://help.squarecloud.app/en-us/article/how-to-create-a-music-bot-lavalink-aarooe/).