Valheim Wiki
Advertisement

This page shows basics and details on how to set up and operate a Valheim dedicated server.

Overview[]

The dedicated server is responsible for relaying RTC communication and providing remote map data, when enabled, advertising the server in the Steam Server Query (in the “other” region). The server does not simulate any of the game logic—it is not server-side authoritative. The authority role is claimed by the clients on locally isolated areas they interact with. However, the server will do some authoritative jobs; when a client connects, it validates Steam IDs using the Steam API, checks its banned and permitted lists, and validates a password and version code.

Parallel processes[]

The dedicated server runs a few services into their own sub-process to be able to serve the RTC relay keep the map data consistent without consuming all the memory and not block each of the tasks. These processes are the following:

Zonesystem & DungeonDB[]

These two are interconnected, both responsible for loading and generating world data. These two need to be in a started state before serving any clients.

Related output lines are:

  • Zonesystem <state> <pid>
  • Added <num> locations, <num> vegetations, <num> environment, <num> biome env setups from <generator>
  • DungeonDB <state> <pid>
  • Load world <world name>
  • Loading <count> zdos, my id <num> data version:<num>
  • Loaded <num> dead zdos
  • Removed <num> OLD generated ZDOS
  • Loaded <num> locations

The lifecycle of these sub-processes are:

  1. Awake: Script is loaded, and initializing
  2. Start: Ready to serve API calls

Game server (Steam A2S)[]

When enabled (which it is by default), the Game server will provide an A2S port that is used to get server information for Steam games. The state is reported with “Game server <state>“ and “Game server connected error” where the latter is and indication of the server not reaching the Steam Connection Manager servers; Check their availability through steamstat.us (unofficial), or alternatively look for the connection log.

The way Steam Query Servers work is that the Game server provides an implementation of the A2S protocol[1], and will register itself with the Steam Master Servers. Once notified, the Master Server will query for an A2S information every 5 minutes, and when fails, it will remove the server from its list.

The connected player counter is updated every 10 minutes or when someone connects/disconnects, however the player list is not populated at the moment.

The lifecycle of this sub-process is:

  1. Initialized: The A2S implementation is loaded and Master Servers were notified for a new server (related output: Server ID <number>)
  2. Connected: Master Server fetched the server details and now listing the server in the region (hardcoded to “other”)

Garbage collector[]

Every 10 minutes, the server will go through the loaded areas and remove anything that is no longer needed in memory. This is reported by “Unloading X unused Assets/Serialized files” lines in the console. The relay is not paused while this is running.

Related Output lines are:

  • Unloading X unused Serialized files
  • Unloading X unused Assets

World Save[]

Every 20 minutes, the server will clone the memory and then write it to the storage. While the memory cloning is on-going, all relay operations are on hold. This usually takes around 20–300 ms, while the storage writing can take up to a few seconds. Relay operations are continued right after the memory clone is done, and the storage operation runs in the background.

When the 20-minute cycle happens, the Garbage Collection is triggered before a world save!

Related output lines are:

  • clone <number>
  • World saved ( <milliseconds>ms )

Networking[]

The server uses UDP packets on every connection; The RTC, Steam CMs, and A2S Server Information. Having a DNS and access to the internet is required to run the server as the Steam API has to be called for validating the client connections, and when enabled, the the Steam Connection Managers needed to be reached.

Ingress IP Ingress Port Egress IP Egress Port
First Interface’s First IP 2456/udp (or -port value) *.cm.steampowered.com (IPs in config/config.vdf, dynamically updated with each server start) 27028-26038/udp
First Interface’s First IP 2457/udp (or -port +1 value) hl2master.steampowered.com (208.64.200.39, 208.64.200.52, 208.64.200.65) 27011-27016/udp


Requirements[]

At the moment, the dedicated server is available for the Windows and Linux operating systems. It can currently be installed using the Steam service (where it is listed in the user's library as a "tool"), or its command line sibling SteamCMD.

The following requirements are unofficial, but are the general consensus. It may still be able to run a dedicated server using less than the listed requirements. Server performance depends on your initial setup, distro/os selection, the number of players and whether you use mods. Modded Valheim Servers will require better hardware. The recommended settings will cover most instances.

Operating System: Windows 7 or newer, Server 2016, 2019 or Linux
Minimum Recommended
CPU Quad-Core Processor (4 Cores) Hexa-Core Processor (6 Cores)
CPU Frequency 2.8 GHz 3.4 GHz+
RAM 2 GB 4 GB+
Storage 2 GB 4 GB+

The server is not CPU-heavy after the world generation is done. Instead, it will load all data into memory, so it will use a considerable amount there. In general, a fresh world usually uses around 1.8–2.4 GB of RAM, each loaded areas (where players are active) take around 100–300 MB, but high-instance areas could demand a lot more. Whenever someone enters a new area, the server will generate that on the fly—at times of exploration the CPU load can be demanding.

Setup[]

Valheim Dedicated Server tool

The guide below is for hosting a dedicated server. You can also play using the built-in server hosting in the Valheim client by selecting the “Start Server” radio button when loading your world. The difference between using the client to host and the dedicated server option is that the server will shut down when you exit the client, but a dedicated server will stay on so long as the program is running and there is an internet connection.

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
Image Features Pulls
lloesche/valheim-server
  • Auto update
  • Auto backup
  • ValheimPlus support
  • BepInEx support
  • Event hooks
  • Extensive logging
over 10 million
mbround18/valheim
  • Auto update
  • Auto backup
  • ValheimPlus support
  • BepInEx support
  • Event hooks
over 5 million

Automated Installation via AMP[]

ValheimAMP

Creating a server using 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. To be able to connect to PlayFab, and enable crossplay, you must also install several dependencies.
sudo apt update && sudo apt install -y libpulse-dev libatomic1 libc6
7. 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.

Connecting[]

Manually[]

  1. Start Valheim
  2. Select your character
  3. From the select world window, select the "Join Game" tab near the top
  4. Find your server's name in the Community servers list and connect to it, or...
  5. Select “Join IP”
  6. Enter the server IP and forwarded port
    • If you’re playing the game on the same computer you are hosting the server on, use 127.0.0.1:2456
    • If you’re playing the game and hosting it on two different computers, use the LAN (local) IP of the server computer. This usually starts with 192.168 and can be found in your router’s list of connected devices. (Example: 192.168.0.2:2456)
    • If you’re connecting to someone else’s server, you may find their server name in the in-game server browser. Or, the host will need to provide the public IP and forwarded port. The host can discover their public IP by visiting https://whatismyipaddress.com/ and selecting the IPv4 address or by Googling “my IP”
  7. Select “Connect”
  8. Enter the server password

Semi-Automated[]

Alternatively, you can set up links by using the Steam protocol.

steam://connect[]

The format for this is: steam://connect/<fqdn/ip>[:<port>]

This link requires that the A2S port is running (2457 by default). It tells Steam to connect to a server—it will prompt the password input outside of Valheim, launch Valheim and you will need to type your password again. The in-game password field is the only one that works, the Steam window field is not recognised by the game yet, so you can’t type anything there.

By default this uses :27015 port, so if you forward your :2457 port to that, you can omit the port section.

Example: steam://connect/valheim-server.example.com:2457

steam://run[]

The format you would need to use is: steam://run/%2Bconnect%20<fqdn/ip>[%3A<port>]

This link will instruct Valheim to connect to a server directly—it works even when the A2S port is not enabled (-public 0). The % characters are needed for most places where you cannot control the embed link correctly—it will translate to the runtime arguments: “+connect <fqdn/ip>[:port]

Example: steam://run/%2Bconnect%20valheim-server.example.com%3A2456

Additional configuration[]

Admins, bans, and whitelist[]

Server hosts are able to whitelist, ban, and make an admin of any users with the permittedlist.txt, bannedlist.txt, and adminlist.txt files located in %UserProfile%\AppData\LocalLow\IronGate\Valheim.

Each file uses the steamID64 of a user to accurately identify their Steam account. This number can be found in several ways:

  • While in-game on your server, press F2 to bring up a menu that will show you connected players and their steamID64
  • Use a 3rd party tool like steamid.io to find a player's steamID64 using their name
  • In the server console, you will see clients and "session requests" from players using their steamID64's

Being an admin allows only the use of admin-specific console commands to manage your server (kick, ban, etc). It does not give access to any other commands such as cheats or debugmode. To make yourself an admin on your server, find your steamID64 using one of the above steps and add it to the adminlist.txt.

For example, if your steamID64 is “1234567890123456”, the file should look like the following:
// List admin players ID  ONE per line
1234567890123456
Make sure there is no whitespace or comments in any lines, each line is read as a whole!

Specifying seed & location of World Save Data[]

Dedicated seed

Currently, the server will create a random seed and give it the name you specify in the -world parameter of the start_headless_server.bat file detailed above, so if you want to host a server with a specific seed, you will need to use a workaround by creating the world by the client and uploading the required files.

  1. Create the seed in singleplayer using a unique world name. For example,
    • Name: “Dedicated”
    • Seed: “pangea”
  2. Make sure to start this new world at least once to get the game to create the necessary files
  3. Change the -world parameter in your copied start_headless_server.bat to your chosen world name (not the seed name). In this example, “Dedicated”

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)

The seed is stored in the .fwl file, that is the only one required if you want to force a fresh, empty world.

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

Updating[]

Every time the game updates, you will also need to update your dedicated server. If the dedicated server version does not match the game version then players cannot connect. It is sufficient (in recent patches) simply to update the Valheim Dedicated Server tool in Steam—no need to use third-party tools.

Backups and transferring worlds[]

Windows: Your worlds are stored in [Drive Letter]:\%UserProfile%\AppData\LocalLow\IronGate\Valheim\worlds

Linux: Your worlds are stored in ~/.config/unity3d/IronGate/Valheim/worlds_local

The above folder is used by the dedicated server tool and the Valheim game’s own system. You can interchangeably choose to play using the dedicated server or the game hosting. It is not suggested to do this simultaneously with the same world—critical errors may occur.

There are two files which constitute all of the data in your world—they should be copied and backed up as a package:

  • [WORLD NAME].db – this contains all of the data in your world which is your “progress” i.e. any player activity which modifies the generated seed—the more exploration or building your do, the larger this file will be.
  • [WORLD NAME].fwl – this contains the metadata of your world which are the seed, generator version, world name, and a unique identifier for map progression. This file is needed in order to generate and load a world, and thus missing it will cause the game to create a new one and wipe your data in the .db even if you have progress in that.

The most obvious indication that there is a data mismatch is that your world name will be displayed in the world list with a different seed than you expect. Other notable indication is when your world looks exactly the same as you expect, but missing your buildings and progression, in that case your DB file was transferred incorrectly. In both case, you need to retrieve your files from a backup, and use BINARY transfer if you upload/download it from a remote storage.

There are also files with a further extension of .old—these are automatically created backup files which will be created every 20 minutes of uptime. To restore from an .old file, simply remove the .old extension and it will work.

You can back up your world and progress simply by copying the .db and .fwl files for your world and placing them in a folder. Additionally, to transfer your world and progress to another player (such as your friend who wants to host a dedicated server), simply transfer both the .db and .fwl files. Make sure you either compress them or use BINARY mode for your transfer!

Steam Cloud interaction[]

Steam Cloud (if enabled) will automatically upload all of the files in the “worlds” folder in AppData to the Steam Cloud when you exit Valheim. You can place a backup subfolder in the worlds folder which will then be backed up using Steam Cloud. You can manually download Steam Cloud files here: https://store.steampowered.com/account/remotestorage

Steam Cloud will also automatically download all files from the “worlds” folder in Steam Cloud to your AppData folder when you open Valheim. I suggest that if you receive a message that there is a file mismatch, do not click any button until you have backed up both sets of files—this can lead to your world becoming irretrievably broken if you did not back up properly.

Frequently asked questions[]

Why does the server lag happen?[]

There are two common cases for a server to be unresponsive:

  1. The client who got assigned to be the chunk-master, the host for an area, cannot fulfill that duty properly. The role is a CPU-heavy duty in terms of parallelism, if the client who connected does not handle threads well, or already overloaded with many background tasks, then everyone will see delays in their actions like accessing chests, opening doors, seeing buildings crumble or trees fall. A workaround is to make the players who can handle this job go first in an area, or reassign the role by asking the current chunk-master to quickly leave the area and re-enter.
  2. World Save is slow to clone the memory. This happens every 20 minutes, and the game announces it before it happens, so it is much easier to identify. There is no workaround for this, but you can ease the problem by not splitting up your group to load many areas at once, and have a faster memory and CPU combination on the server to speed up the cloning process.

Some sources also point at the server being bandwidth-limited. That is usually not a problem, or a problem of hardware that would be hard to replace. The thing is that the host, the chunk-master will need to handle many UDP packets, and outside of the host hardware CPU limitations, you can run into networking hardware not capable for the server side. Clients are usually fine, but the dedicated server will have multiple times the load of a single client in terms of packet counts. Some mods do try to combat this by either compressing the sent packets or grouping them, but the real solution is to host your server in a more capable environment.

Why does desync happen?[]

This is an extension to the Lag problem, sometimes it can happen that the clients are dropped out from the server but still connected and doing things. While in a group this can be recognised much easier when two players see different states of an area, but when you play alone this is really hard to recognise. Typically, what you want to do is to reconnect to the server, and once you see this happening with your connection, you just have to look out for indications of the symptoms.

My progress got reverted, what can I do?[]

This is partially the previous desync problem, and another common mistake by shutting down the server incorrectly. The shutdown progression loss can be easily recognised as it happens after you kill your server. The way to prevent is to correctly shutdown your server by sending a SIGINT signal to it instead of terminating the process. On windows this can be achieved by sending a CTLR+C and accepting with a Y to the command window, on Linux you need to set up a trap and send the right signal or set up your service configuration to use SIGINT. As for restoring progress, you have no options, as it either never existed on the server or got lost by not saving the memory state.

References[]

Advertisement