# Host a Lavalink-Server

There is an official [Getting-started](https://lavalink.dev/getting-started/index.html) Guide from [Lavalink](https://lavalink.dev/), I recommend checking it out!

1. Install <mark style="color:red;">Java 17</mark> or higher. You can download it [here](https://www.azul.com/downloads/?package=jdk#zulu).&#x20;
   1. *I recommend Java 20 or higher*
2. Download the latest <mark style="color:red;">`Lavalink.jar`</mark> from [GitHub-Releases-Page](https://github.com/lavalink-devs/Lavalink/releases/latest). or directly via [my download-lavalink-server script](#download-latest-lavalink-server-version)
3. Now configure the Lavalink-Server via an `application.yml` file or env-variables. \
   \&#xNAN;*For that check out the* [*configuration*](https://lavalink.dev/configuration/index.html) *page to learn out how.*
   1. [*My configuration guide*](https://lc4.gitbook.io/lavalink-client/host-a-lavalink-server/application.yml-configuration)
4. Run Lavalink with `java -jar Lavalink.jar.`
   * To perma-host lavalink you can use multiple ways:
     1. [pm2 ](https://lc4.gitbook.io/lavalink-client/host-a-lavalink-server/host-via-pm2)(node process manager package)
     2. [systemd ](https://lc4.gitbook.io/lavalink-client/host-a-lavalink-server/host-via-systemd)(linux distro background process manager)
     3. [screen ](https://lc4.gitbook.io/lavalink-client/host-a-lavalink-server/host-via-screen)(old)
5. Now test if you can use the lavalink server:

```bash
curl -H "Authorization: yourverystrongpassword" http://localhost:2333/v4/info | json_pp
```

<mark style="color:red;">`http://localhost:2333`</mark> is the url-domain of the lavalink server, aka on the same machine where it's hosted that's why <mark style="color:red;">`localhost`</mark>, and <mark style="color:red;">`2333`</mark> is the <mark style="color:red;">`port`</mark>. if you have a remote ip, you can use the ip / domain.

<mark style="color:red;">`/v4/info`</mark> is the request path, and <mark style="color:red;">`-H "Authorization: yourverystrongpassword"`</mark> is the Authorization header, aka <mark style="color:red;">`password`</mark> configured in lavalink server.\
That request-path returns all information of the lavalink-server which is same as <mark style="color:red;">**`player.node.info`**</mark>

<mark style="color:red;">`| json_pp`</mark> is a default linux package, to pretty-print the output (json) \[optional]

### Max Memory Limit

when you provide `-Xmx4G` for example, you tell java to allocate 4gigs of memory to that java-process, aka lavalink can't use more

### Spotify, Deezer, Apple-Music, etc. etc.

There are Lavalink-Server Plugins, check out [my example](https://lc4.gitbook.io/lavalink-client/host-a-lavalink-server/application.yml-configuration/with-spotify-deezer-apple-music-etc.)

## <mark style="color:red;">Download Latest Lavalink Server Version</mark>

Following BASH (Linux \*.sh) Script, **downloads the latest lavalink** version, including pre-releases.\
It also deletes the old, pre-existing Lavalink.jar file, if available

<pre class="language-bash" data-title="updateLavalink.sh" data-line-numbers><code class="lang-bash"><strong># Delete old Lavalink.jar if available
</strong>if [[ -f "./Lavalink.jar" ]]
then
  rm Lavalink.jar
fi
# get the content of all releases
content=$(curl --silent https://api.github.com/repos/lavalink-devs/Lavalink/releases)
# get latest release (incl. pre-releases)
releaseName=$(jq -r 'map(select(.prerelease)) | first | .tag_name' &#x3C;&#x3C;&#x3C; "${content}")
# download latest release
wget "https://github.com/lavalink-devs/Lavalink/releases/download/${releaseName}/Lavalink.jar" -O Lavalink.jar
</code></pre>

Or just browse through the [Releases Page](https://github.com/lavalink-devs/Lavalink/releases) or download the [latest stable release](https://github.com/lavalink-devs/Lavalink/releases/latest/download/Lavalink.jar)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lc4.gitbook.io/lavalink-client/host-a-lavalink-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
