Valheim ships a free dedicated server for Linux that you can download anonymously with SteamCMD, Valve's command-line Steam client. Running it on your own server keeps the world online when the host player logs off and gives you full control over passwords, admins and backups. In this tutorial you will install the Valheim server on Ubuntu 24.04, run it as a systemd service under its own user, open the required ports and set up world backups.
Prerequisites
To follow this guide you need:
- A server running Ubuntu 24.04 LTS (x86_64), for example a CubePath VPS. Plan for 2 CPU cores and 4 GB of RAM for a small group; larger or heavily built worlds use more memory.
- About 5 GB of free disk space for the server files and world saves.
- A non-root user with
sudoprivileges. - A copy of Valheim on Steam on the computer you will play from.
Step 1 - Installing SteamCMD
SteamCMD is in Ubuntu's multiverse repository and needs 32-bit libraries, so enable both first:
sudo add-apt-repository multiverse
sudo dpkg --add-architecture i386
sudo apt update
Install the package. During installation you will be asked to accept the Steam license agreement; select I AGREE to continue:
sudo apt install steamcmd
The binary is installed as /usr/games/steamcmd. Check it:
ls -l /usr/games/steamcmd
Step 2 - Creating a dedicated user
Game servers should never run as root. Create a regular user called steam with its own home directory, which will hold the server files and the world saves:
sudo useradd -m -s /bin/bash steam
Switch to that user for the next step:
sudo -iu steam
Step 3 - Downloading the Valheim server
The Valheim dedicated server is Steam app 896660 and can be downloaded without a Steam account. Note that +force_install_dir must come before +login:
/usr/games/steamcmd +force_install_dir /home/steam/valheim +login anonymous +app_update 896660 validate +quit
The first run also updates SteamCMD itself, so it takes a few minutes. It ends with:
Success! App '896660' fully installed.
Confirm that the server binary is there, then return to your sudo user:
ls /home/steam/valheim/valheim_server.x86_64
exit
Step 4 - Creating the systemd service
Valheim includes a start_server.sh example, but a systemd unit is a better fit: it starts the server at boot, restarts it after a crash, logs to the journal and can update the game before every start.
Pick the values you will use:
- Server name (
-name): what players see in the server list. - World name (
-world): the save file name. A new world with this name is created on first start. - Password (
-password): at least 5 characters and must not be contained in the server name, otherwise the server refuses to start.
Create the unit file:
sudo nano /etc/systemd/system/valheim.service
[Unit]
Description=Valheim dedicated server
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=steam
Group=steam
WorkingDirectory=/home/steam/valheim
Environment=LD_LIBRARY_PATH=/home/steam/valheim/linux64
Environment=SteamAppId=892970
ExecStartPre=-/usr/games/steamcmd +force_install_dir /home/steam/valheim +login anonymous +app_update 896660 +quit
ExecStart=/home/steam/valheim/valheim_server.x86_64 -nographics -batchmode -name "CubePath Vikings" -port 2456 -world "Midgard" -password "your_server_password" -public 1 -savedir /home/steam/valheim-data
KillSignal=SIGINT
TimeoutStartSec=600
TimeoutStopSec=60
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
What the less obvious lines do:
SteamAppId=892970is the Valheim game's app ID, which the server needs to register with Steam (the server download itself is896660).ExecStartPrechecks for game updates on every start, so a restart is all you need after a Valheim patch. The leading-lets the server start anyway if Steam is unreachable, andTimeoutStartSecgives the update time to finish.KillSignal=SIGINTmakessystemctl stopshut the server down the same way asCTRL+Cdoes, which saves the world before exiting.-public 1lists the server in the in-game community browser. Use-public 0to hide it and connect only by IP.-savedirkeeps worlds, the admin list and the ban list in/home/steam/valheim-datainstead of a hidden directory.
If players on Xbox or the Microsoft Store version need to join, append -crossplay to the ExecStart line.
Reload systemd and start the server:
sudo systemctl daemon-reload
sudo systemctl enable --now valheim
Step 5 - Verifying that the server is running
Follow the log. The world is generated or loaded, and after a minute or two you should see the server register with Steam:
sudo journalctl -u valheim -f
... Game server connected
Press CTRL+C to stop following. The service status should be active (running):
sudo systemctl status valheim --no-pager
Check that the server is listening on its UDP ports:
sudo ss -ulpn | grep valheim
UNCONN 0 0 0.0.0.0:2456 0.0.0.0:* users:(("valheim_server.",pid=4121,fd=...))
UNCONN 0 0 0.0.0.0:2457 0.0.0.0:* users:(("valheim_server.",pid=4121,fd=...))
Step 6 - Opening the firewall
Valheim uses the port you set with -port (2456) and the next one (2457), both UDP. If UFW is enabled, allow them:
sudo ufw allow 2456:2457/udp
sudo ufw status
Now connect from the game. In Valheim, choose Join Game, click Join IP and enter your_server_ip:2456, then type the password. If you used -public 1, the server also appears under the Community tab after a few minutes.
Step 7 - Adding admins
Admins can kick and ban players and use the in-game console commands. The server reads the admin list from adminlist.txt in the save directory, one SteamID64 per line. You can find a player's SteamID64 in the in-game F2 connection panel or on their Steam profile URL.
sudo -u steam nano /home/steam/valheim-data/adminlist.txt
76561198000000000
Restart the server so the change applies:
sudo systemctl restart valheim
In the same directory, bannedlist.txt and permittedlist.txt (a whitelist, when not empty) use the same format.
Step 8 - Backing up the world
A Valheim world is two files in /home/steam/valheim-data/worlds_local/: Midgard.db holds the world data and Midgard.fwl its metadata. Valheim writes its own rotating backups there, but those sit on the same disk, so also keep copies elsewhere.
Create a backup directory and add a cron job for the steam user that archives the worlds every night at 05:00 and deletes archives older than 14 days:
sudo -u steam mkdir -p /home/steam/backups
sudo -u steam crontab -e
0 5 * * * tar -czf /home/steam/backups/valheim-$(date +\%F).tar.gz -C /home/steam/valheim-data worlds_local && find /home/steam/backups -name 'valheim-*.tar.gz' -mtime +14 -delete
The % signs are escaped because cron treats a bare % as a newline. Run the same tar command once by hand to confirm it works, then copy the backups directory off the server regularly (for example with rsync to another machine or object storage).
To restore, stop the server, extract the archive back into /home/steam/valheim-data, and start it again:
sudo systemctl stop valheim
sudo -u steam tar -xzf /home/steam/backups/valheim-2026-09-25.tar.gz -C /home/steam/valheim-data
sudo systemctl start valheim
Troubleshooting
- The service exits right after starting. Check
sudo journalctl -u valheim -n 50. The most common cause is a password shorter than 5 characters or one that appears in the server name. - The server runs but nobody can connect. Make sure UDP 2456 and 2457 are allowed in UFW and in any external firewall, and that you are joining on port 2456, not 2457.
- The server does not appear in the Community list. Listing can take several minutes and is sometimes unreliable. Joining by IP works regardless.
- Players see a version mismatch. The game client was updated but the server was not. Run
sudo systemctl restart valheim; theExecStartPreline pulls the update.
Conclusion
Your Valheim dedicated server now runs on Ubuntu 24.04 as a systemd service, updates itself on restart and keeps nightly world backups. As next steps, you can move an existing single-player world to the server by copying its .db and .fwl files into worlds_local and setting -world to its name, restrict access with permittedlist.txt, or install BepInEx if your group wants server-side mods.
