> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shardcloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Host a Lavalink Server

> Learn how to create and host your own Lavalink music server on Shard Cloud.

## Introduction

Lavalink is a standalone audio sending node for Discord bots. It allows you to stream high-quality music to Discord without consuming your bot's resources.

## Downloading Lavalink

<Steps>
  <Step title="Get Lavalink JAR">
    Download the latest Lavalink release from the [official GitHub
    releases](https://github.com/lavalink-devs/Lavalink/releases). Download the
    `Lavalink.jar` file.
  </Step>

  <Step title="Create Configuration File">
    Create an `application.yml` file with your Lavalink configuration.
  </Step>
</Steps>

## Configuration File

Create an `application.yml` file:

```yaml application.yml theme={null}
server:
  port: 80
  address: 0.0.0.0

lavalink:
  server:
    password: "your-secure-password-here"
    sources:
      youtube: true
      bandcamp: true
      soundcloud: true
      twitch: true
      vimeo: true
      http: true
      local: false
    bufferDurationMs: 400
    frameBufferDurationMs: 5000
    youtubePlaylistLoadLimit: 6
    playerUpdateInterval: 5
    youtubeSearchEnabled: true
    soundcloudSearchEnabled: true
    gc-warnings: true

logging:
  file:
    path: ./logs/
  level:
    root: INFO
    lavalink: INFO
```

<Warning>
  **Important**: Set the `port` to `80` for Shard Cloud hosting.
</Warning>

## Shard Cloud Configuration

Create a `.shardcloud` file:

```systemd .shardcloud theme={null}
DISPLAY_NAME=Lavalink Server
DESCRIPTION=Lavalink Audio Server
MAIN=Lavalink.jar
MEMORY=1024
VERSION=recommended
SUBDOMAIN=my-lavalink
```

<Note>
  The `SUBDOMAIN` gives you a URL like `my-lavalink.shardweb.app` to connect
  your bot.
</Note>

## Deploying

<Steps>
  <Step title="Prepare Files">
    Create a folder with: - `Lavalink.jar` - `application.yml` - `.shardcloud`
  </Step>

  <Step title="Create ZIP Archive">
    Compress the folder into a `.zip` file.
  </Step>

  <Step title="Upload to Shard Cloud">
    Go to [Shard Cloud Dashboard](https://shardcloud.app/dash/applications) and
    upload your ZIP file.
  </Step>
</Steps>

## Connecting Your Bot

When connecting to your Lavalink server from your Discord bot:

* **Host**: `my-lavalink.shardweb.app`
* **Port**: `443` (SSL/HTTPS)
* **Password**: Your configured password
* **Secure**: `true`

### Example Connection (discord.js + Shoukaku)

```javascript theme={null}
const { Shoukaku, Connectors } = require("shoukaku");

const nodes = [
  {
    name: "main",
    url: "my-lavalink.shardweb.app:443",
    auth: "your-secure-password-here",
    secure: true,
  },
];

const shoukaku = new Shoukaku(new Connectors.DiscordJS(client), nodes);
```

### Example Connection (discord.py + wavelink)

```python theme={null}
import wavelink

node = wavelink.Node(
    uri='https://my-lavalink.shardweb.app:443',
    password='your-secure-password-here'
)
```

<Note>
  Always use port **443** and `secure: true` when connecting to your Lavalink on
  Shard Cloud.
</Note>

## Additional Resources

* [Lavalink GitHub](https://github.com/lavalink-devs/Lavalink)
* [Lavalink Documentation](https://lavalink.dev/)

## Troubleshooting

<AccordionGroup>
  <Accordion title="Connection refused">
    * Verify the password matches - Use port 443 with secure/SSL enabled - Check
      that your Lavalink server is running
  </Accordion>

  <Accordion title="Out of memory">
    Increase the `MEMORY` value in your `.shardcloud` config (minimum 512MB
    recommended).
  </Accordion>

  <Accordion title="No audio sources">
    Check your `application.yml` to ensure the required sources are enabled.
  </Accordion>
</AccordionGroup>
