Skip to main content

Valheim

A guide to configure a dedicated server for Valheim on Linux. Basically this: https://valheim.fandom.com/wiki/Dedicated_servers

Prerequisites

  • Ubuntu 24.04 or later
  • sudo privileges
  • SteamCMD installed
  • A dedicated service account on the system named steam

Step 1: Prerequisites

Create steam user

Create new steam user to run the server.

sudo adduser steam

Follow the prompts. I just left things blank/default. Mash enter. Save the password in case you need it for some reason. I keep the credential in Bitwarden.

Install steamcmd

https://developer.valvesoftware.com/wiki/SteamCMD#Downloading_SteamCMD

Skip the create user step since we did that already. Add the necessary repositories and install steamcmd.

sudo add-apt-repository multiverse; sudo dpkg --add-architecture i386; sudo apt update;
sudo apt install steamcmd

Step 2: Download the server files

  1. Create a folder where you wish to install your Valheim dedicated server
sudo su - steam
mkdir valheim
  1. Install SteamCMD

This was done as part of the Satisfactory setup, so I re-used the existing steam user

  1. Create a Valheim install and validate script named InstallUpdate.sh
nano installupdate.sh
  1. Place the following code in this script:
#!/bin/sh
/usr/games/steamcmd +@sSteamCmdForcePlatformType linux +force_install_dir /home/steam/valheim +login anonymous +app_update 896660 -beta public validate +quit
  1. Make the installupdate.sh script executable:
chmod +x installupdate.sh
  1. 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
  1. Run the installupdate.sh script to install. Whenever Valheim is updated, run this script again.

Step 3: Setting up a Valheim Dedicated Server

  1. Create a script named valheimserver.sh in your Valheim install directory (/home/steam/valheim)
  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 "REALLY_COOL_NAME" -port 2456 -nographics -batchmode -world "REALLY_COOL_WORLD_NAME" -password "REALLY_SECURE_PASSWORD!" -public 1
export LD_LIBRARY_PATH=$templdpath
  1. Save and run the valheimserver.sh script to start the server.

Step 4: Port Forwarding / Remote Access

  1. Add an incoming rule to your network and system firewall to allow UDP port 2456 (game port) and 2457 (Steam query port).

Step 5 (Optional): Create a systemd service to manage the server

  1. Create a unit file in /etc/systemd/system. Name it valheimserver.service or similar.
sudo nano /etc/systemd/system/valheimserver.service
  1. Place the following contents in the service file to have the server update prior to starting. Remove the line beginning with ExecStartPre if you don't want the server to automatically update when the service starts.
[Unit]
Description=Valheim dedicated server
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target

[Service]
ExecStartPre=/home/steam/valheim/installupdate.sh
ExecStart=/home/steam/valheim/valheimserver.sh
User=steam
Group=steam
Restart=on-failure
RestartSec=60
KillSignal=SIGINT
WorkingDirectory=/home/steam/valheim

[Install]
WantedBy=multi-user.target
  1. Enable and start the service.
sudo systemctl enable valheimserver.service
sudo systemctl start valheimserver.service
  1. Verify that the service is running.
sudo systemctl status valheimserver.service

If there are errors, check with journalctl -xeu valheimserver.service and troubleshoot, then restart the service with sudo systemctl restart valheimserver.service.