How to make lavalink server.

How to make lavalink server.


5 min read

This article may contain outdated information. Both the extension and this article will be removed in the future.
What are we doing today?
Welcome to the Lavalink Getting Started guide. If you're new to Lavalink, follow these steps to get started:

Lavalink is a standalone program, written in Java. It's a lightweight solution for playing music from sources such as YouTube or Soundcloud. Unlike raw voice solutions, such as VoiceNext, Lavalink can handle hundreds of concurrent streams, and supports sharding.

Configuring Java

In order to run Lavalink, you must have Java 13 or greater installed. Certain Java versions may not be functional with Lavalink, so it is best to check the Requirements before downloading. The latest releases can be found here.

Make sure the location of the newest JRE's bin folder is added to your system variable's path. This will make the java command run from the latest runtime. You can verify that you have the right version by entering java -version in your command prompt or terminal.

Next, head over to the releases tab on the Lavalink GitHub page and download the Jar file from the latest version. Alternatively, stable builds with the latest changes can be found on their CI Server.

The program will not be ready to run yet, as you will need to create a configuration file first. To do so, create a new YAML file called application.yml, and use the example file, or copy this text:

server: # REST and WS server
  port: 2333
    enabled: false # Whether to enable HTTP/2 support
#  name: # Name of the plugin
#    some_key: some_value # Some key-value pair for the plugin
#    another_key: another_value
#    - dependency: "com.github.example:example-plugin:1.0.0" # required, the coordinates of your plugin
#      repository: "" # optional, defaults to the Lavalink releases repository by default
#      snapshot: false # optional, defaults to false, used to tell Lavalink to use the snapshot repository instead of the release repository
#  pluginsDir: "./plugins" # optional, defaults to "./plugins"
#  defaultPluginRepository: "" # optional, defaults to the Lavalink release repository
#  defaultPluginSnapshotRepository: "" # optional, defaults to the Lavalink snapshot repository
    password: "youshallnotpass"
      # The default Youtube source is now deprecated and won't receive further updates. Please use instead.
      youtube: false
      bandcamp: true
      soundcloud: true
      twitch: true
      vimeo: true
      nico: true
      http: true # warning: keeping HTTP enabled without a proxy configured could expose your server's IP address.
      local: false
    filters: # All filters are enabled by default
      volume: true
      equalizer: true
      karaoke: true
      timescale: true
      tremolo: true
      vibrato: true
      distortion: true
      rotation: true
      channelMix: true
      lowPass: true
    bufferDurationMs: 400 # The duration of the NAS buffer. Higher values fare better against longer GC pauses. Duration <= 0 to disable JDA-NAS. Minimum of 40ms, lower values may introduce pauses.
    frameBufferDurationMs: 5000 # How many milliseconds of audio to keep buffered
    opusEncodingQuality: 10 # Opus encoder quality. Valid values range from 0 to 10, where 10 is best quality but is the most expensive on the CPU.
    resamplingQuality: LOW # Quality of resampling operations. Valid values are LOW, MEDIUM and HIGH, where HIGH uses the most CPU.
    trackStuckThresholdMs: 10000 # The threshold for how long a track can be stuck. A track is stuck if does not return any audio data.
    useSeekGhosting: true # Seek ghosting is the effect where whilst a seek is in progress, the audio buffer is read from until empty, or until seek is ready.
    youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
    playerUpdateInterval: 5 # How frequently to send player updates to clients, in seconds
    youtubeSearchEnabled: true
    soundcloudSearchEnabled: true
    gc-warnings: true
      #ipBlocks: ["", "..."] # list of ip blocks
      #excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
      #strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
      #searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
      #retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times
    #youtubeConfig: # Required for avoiding all age restrictions by YouTube, some restricted videos still can be played without.
      #email: "" # Email of Google account
      #password: "" # Password of Google account
    #httpConfig: # Useful for blocking bad-actors from ip-grabbing your music node and attacking it, this way only the http proxy will be attacked
      #proxyHost: "localhost" # Hostname of the proxy, (ip or domain)
      #proxyPort: 3128 # Proxy port, 3128 is the default for squidProxy
      #proxyUser: "" # Optional user for basic authentication fields, leave blank if you don't use basic auth
      #proxyPassword: "" # Password for basic authentication

    enabled: false
    endpoint: /metrics

  dsn: ""
  environment: ""
#  tags:
#    some_key: some_value
#    another_key: another_value

    path: ./logs/

    root: INFO
    lavalink: INFO

    enabled: true
    includeClientInfo: true
    includeHeaders: false
    includeQueryString: true
    includePayload: true
    maxPayloadLength: 10000

      max-file-size: 1GB
      max-history: 30

YAML is whitespace-sensitive. Make sure you are using a text editor which properly handles this. There are a few values to keep in mind.

host is the IP of the Lavalink host. This will be by default, but it should be changed as it is a security risk. For this guide, set this to as we will be running Lavalink locally.

port is the allowed port for the Lavalink connection. 2333 is the default port, and is what will be used for this guide.

password is the password that you will need to specify when connecting. This can be anything as long as it is a valid YAML string. Keep it as youshallnotpass for this guide.

When you are finished configuring this, save the file in the same directory as your Lavalink executable.

Keep note of your port, address, and password values, as you will need them later for connecting.

Open your command prompt or terminal and navigate to the directory containing Lavalink. Once there, type java -jar Lavalink.jar. You should start seeing log output from Lavalink.

If everything is configured properly, you should see this appear somewhere in the log output without any errors:

[main] lavalink.server.Launcher: Started Launcher in 5.769 seconds (JVM running for 6.758)

If it does, congratulations🎉. We are now ready to interact with it using DSharpPlus.