Valheim Dedicated Server

## Server Requirements

**Operating System: Windows 7, 8 or 8.1, Server 2016, 2019 or Linux**
 **CPU Frequency** | 2.8 GHz
 **RAM** | 2 GB
 **Storage** | 2 GB

**Note**: Server performance depends on your initial setup, distro/os selection and whether you use mods. Modded Valheim Servers will require better hardware. The recommended settings will cover most instances.

# Automated Setup

## Docker

If your server is running Docker, you can find community images on Docker Hub. At the time there is no offical docker image for Valheim dedicated server available.

**List of popular images**
* Auto backup
* ValheimPlus support
* BepInEx support
* Event hooks
* Extensive logging
 mbround18/valheim | * Auto update
* Auto backup
* ValheimPlus support
* BepInEx support
* Event hooks

## Automated Installation via AMP

AMP is a popular game server management panel you can run on your own PC/server that supports Valheim and makes it easier to get the server going from its web interface. You can run it on both Windows and Linux. See the Video Tutorial on YouTube. AMP is commercial software, starting at approximately $10 USD as a one-time cost for up to 5 game server instances and free lifetime updates.

Once you have AMP itself up and running (Tutorial and Guide), click "Create Instance" and then select "Valheim" from the list of games. Once you've done that, select "Create Instance".

After that, double click the new Valheim instance to manage it and select "Update" from the status screen. This will download the Valheim server and required files.

Once the download is complete you can hit Start and after a few moments the server will start up. Once the startup has completed you can connect as normal.

# Manual Setup

## Step 1: Download the Server files

### Windows

1. Create a folder where you wish to install your Valheim dedicated server
2. Download SteamCMD into that folder
3. Create a batch file named `InstallUpdate.bat`
4. Place the following code in this batch file:
```
@echo off

steamcmd.exe +force_install_dir "C:\Your\Valheim\Folder" +login anonymous +app_update 896660 -beta none validate +quit

```

5. Right-click `InstallUpdate.bat` and Run as Administrator
6. Your game server files will be downloaded into the folder path used in the batch file
### Linux

1. Create a folder where you wish to install your Valheim dedicated server
2. Install SteamCMD
3. Create a Valheim install and validate script named `InstallUpdate.sh`
4. Place the following code in this script (make sure you edit the path)

```
#!/bin/sh
steamcmd +@sSteamCmdForcePlatformType linux +force_install_dir /path/to/server +login anonymous +app_update 896660 -beta none validate +quit

```

5. Make this script executable

```
sudo chmod +x /path/to/script

```

6. Run the script to install. Whenever Valheim is updated, run this script again.
## Step 2: Setting up a Valheim Dedicated Server

### Windows

1. Create a batch file named `StartServer.bat` in your Valheim server folder from Step 1
2. Place the following code in this batch file:

```
@echo off
set SteamAppId=892970
echo "Starting server PRESS CTRL-C to exit"
valheim\_server.exe -nographics -batchmode -name "YourWorldName" -port 2456 -world "YourWorldFilename" -password "YourPassword" -public 1

```

3. Right-click `StartServer.bat` and Run as Administrator to start your server
### Linux

1. Create a script named `valheim.sh` in your Valheim install directory
2. Place the following code in this script

```
#!/bin/sh
export templdpath=$LD\_LIBRARY\_PATH
export LD\_LIBRARY\_PATH=./linux64:$LD\_LIBRARY\_PATH
export SteamAppID=892970

echo "Starting server PRESS CTRL-C to exit"
./valheim_server.x86_64 -name "<servername>" -port 2456 -nographics -batchmode -world "<worldname>" -password "<serverpassword>" -public 1
export LD\_LIBRARY\_PATH=$templdpath

```

3. Save and run this script to start the server
## Step 3: Port Forwarding / Remote Access

Add an incoming rule to your Windows Firewall to allow UDP port (game port) `2456`, (Steam query port) `2457`.

You may additionally need to add a forwarding rule to your network router. You can use PortForward.com to read how to do this.

## Location of World Save Data

To locate your save folder, navigate to this folder:

`%userprofile%/AppData/LocalLow/IronGate/Valheim/Worlds`
For linux, navigate to this directory:

`$HOME/.config/unity3d/IronGate/Valheim/worlds`
There will be two files:

* `Dedicated.db` (your map data)
* `Dedicated.fwl` (your identifier which includes your worldname and seed)

## Location of Server Log Files

### Linux

Connection logs are located under **`/home/your-username/.steam/logs`**

1. Connection logs for the valheim server are named **`connection_log_2456.txt`**
2456 is the port number your server is listening on (**`2456`** is the default value)
Server logs require you to edit the **`valheim.sh`**-file (or whatever name you called your script to start the server) in order to be saved.

2. Open your **`valheim.sh`**-file in any text editor
3. On the line starting with **`./valheim_server.x86_64`**, append the following:

```
>> /tmp/valheim_log.txt < /dev/null &

```

Your file should now look something like this:

```
#!/bin/sh
export templdpath=$LD\_LIBRARY\_PATH
export LD\_LIBRARY\_PATH=./linux64:$LD\_LIBRARY\_PATH
export SteamAppID=892970

echo "Starting server PRESS CTRL-C to exit"
./valheim_server.x86_64 -name "<servername>" -port 2456 <-nographics> <-batchmode> -world "<worldname>" -password "<serverpassword" -public 1 >> /tmp/valheim_log.txt < /dev/null &
export LD\_LIBRARY\_PATH=$templdpath

```

* `>> /tmp/valheim_log.txt` tells the linux kernel to pipe anything received on `stdout` to this text file instead.
* `< /dev/null &` is used to instantly send EOF(End of File) to the program, so that it doesn't wait for input
	+ `/dev/null`, the null device, is a special file that discards all data written to it, but reports that the write operation succeeded, and provides no data to any process that reads from it, yielding EOF immediately.
	+ `&` is a special type of command separator used to background the preceding process. ref