Valheim Wiki
Advertisement

Requirements

The following requirements are unofficial, but are the general consensus amongst official Helpers in the Valheim Discord. You may still be able to run a dedicated server using less than the listed requirements. This is just a guided starting point. Note that the more players you have, the higher these requirements will need to be to sustain performance!

Minimum

  • 2 cores of 2 GHz x86 CPU
  • 4 GB RAM

Recommended

  • 2 cores of 3 GHz x86 CPU
  • 6 GB of RAM

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.

As for the operating system itself:

  • Windows 10 or newer, or equivalent Windows Server version
  • Linux with kernel 4 or newer
    • glibc (musl and libc is not enough)
    • musl
    • sdl2


Overview of the Dedicated Server

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 a locally isolated areas they are 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, 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 needs 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 ( <miliseconds>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


Setting up and running the Server

Valheim Dedicated Server tool.jpg

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.

1. Download the Valheim Dedicated Server Tool

  • The "Valheim Dedicated Server" tool is available in your Steam library. Against many assumptions, you do not have to own Valheim to be able to access this tool, it should be available on every Steam Account. Download and install the "Valheim Dedicated Server" tool to proceed.

2. Configure the Server

  1. Go to the "Valheim Dedicated Server" application folder. If you installed it from Steam, you can right-click "Valheim Dedicated Server" in your library and select Manage > Browse Local Files
    • Note: The Valheim Dedicated Server Manual PDF file in this folder is also a good resource
  2. In the folder there is a BAT file named "start_headless_server"
    1. This file will be overwritten by Steam if it updates, so make a copy of it
    2. Right-click and edit the copy using Notepad (Alternatively, use Notepad++)
  3. Change the following values on the last line of this file
    • -name “My server”: The name of your server as it appears on the in-game community server browser. Leave this as "My server" or change to something else of your liking
    • -world “Dedicated”: The name of the Valheim World you wish to host on the server. This is also the name of the world file located in %UserProfile%\AppData\LocalLow\IronGate\Valheim\worlds. If you already have a world in mind, use its name here
    • -port 2456: This is the port that Valheim will connect to the server on. Leave this as its default value unless you know what you're doing
    • -password “secret”: The password used to access the Valheim world. Minimum password length is 5 characters
    • (Optional) -savedir [PATH]: Overrides the default save path where worlds and permission files (e.g. adminlist.txt) are stored
      • Example: -savedir "C:/Games/Valheim"
      • Default path for WINDOWS: “../%USERPROFILE%/AppData/LocalLow/ IronGate/Valheim”
      • Default path for LINUX: “~/.config/unity3d/IronGate/Valheim”
    • (Optional) -public 1: This shows (1) or hides (0) your server from the community server browser. Since 1 is the default, there is no need to include it. In other words, setting -public 1 is functionally meaningless. However, setting -public 0 will hide your server from the server browser and require players to connect to it using the "Join IP" button.
  4. Save your changes

3. Start the Server

  • Double-click the copied start_headless_server file you made in step #2 to run the server


IMPORTANT:

When you want to shut down the server, DO NOT USE THE CLOSE BUTTON on the window. In order to let the server properly shut down, send a SIGINT via the CTLR+C combination to it ONCE (confirm with a Y in windows). This will make sure that the server is shut down with a world save.


Port Forwarding

To allow other players to connect to your server from the internet you will need to set up port forwarding. This is usually configured on your router so consult its documentation or read a guide to find the steps on how to do this. There is a website (https://portforward.com) that is a useful resource for this. The port numbers you need to forward are 2456-2457.

NOTE:

Port triggering is also possible, but keep in mind that will only expose the server when a local network connection is using the server, meaning it is essentially the same if you were using the in-game hosting option; The server host (or someone on the same network) would need to be connected to the server.


Connecting to the Server

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

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). What it does is that 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 the only one that works, the steam window field is not recognised by the game yet, so you can 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, 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

Dedicated seed.jpg

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"

If your server is a different computer, you can find the world files in %UserProfile%\AppData\LocalLow\IronGate\Valheim\worlds. Using the example above, they will be named Dedicated.db and Dedicated.fwl. Simply copy/paste these files to the same directory on your server and update your start_headless_server.bat file's -world parameter to your chosen world name (not the seed name).

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


Updates

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. This 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 fulfil 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 keep 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 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 group this can be recognised much easier when two players see different states of an area, 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 seen 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