How to set up a Valheim online game server
Step-by-step guide to installing and configuring a Valheim online game server with optimization and security.

How to set up a Valheim online game server

0 Shares
0
0
0
0

Why is setting up a dedicated Valheim server important for the multiplayer experience?

The Valheim Online Game Server Setup Guide is one of the most useful resources for server administrators, gamers, and hosting providers to create a reliable multiplayer environment. This guide will walk you through the process of installing, configuring, securing, updating, and optimizing a dedicated server/virtual private server (VPS) for Valheim on distributions from scratch. Debian/Ubuntu And with the option Docker We also cover tips related to choosing the optimal location, anti-DDoS protection, and mod management.

How to Set Up a Valheim Online Game Server — Prerequisites and Decisions

Before you begin, you need to make a few technical decisions. These decisions have a direct impact on performance, stability, and player experience.

Server type

Lightweight VPS (2 cores, 2–4 GB RAM) Suitable for small groups.
Cloud or physical server Recommended for public or modded servers with a fast single-core CPU, NVMe, and 4–8+ GB of RAM.

Location

Choose a location closest to the largest number of players (EU: Frankfurt/Amsterdam, NA: New York/Los Angeles, Asia: Singapore/Tokyo). A provider with 85+ global locations And BGP networking can reduce ping.

Protection

For public servers Definitely. Use an anti-DDoS server to mitigate UDP flood and amplification attacks.

Operating system and permissions

Suggestion: Ubuntu 20.04/22.04 Or Debian 11/12. SSH access and a non-root user are required to run the server.

Install SteamCMD and download Valheim Dedicated Server

This section explains the steps for creating a dedicated user, installing prerequisites, and downloading server files with SteamCMD.

Create a dedicated user and install prerequisites

sudo apt update && sudo apt upgrade -y
sudo apt install -y lib32gcc-s1 lib32stdc++6 curl wget screen unzip
sudo adduser --disabled-login --gecos "Valheim Server" valheim
sudo su - valheim

Install SteamCMD

Inside the user valheim Create the steamcmd folder and perform the installation:

mkdir ~/steamcmd && cd ~/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz

Download/Update Valheim Server

Use SteamCMD to install or update a dedicated server. Valheim Dedicated Server App ID: 896660.

./steamcmd.sh +login anonymous +force_install_dir ./valheim_server +app_update 896660 validate +quit

Server files in ./valheim_server They are placed.

Configuring and running the Valheim server

This section explains startup scripts, important parameters, and how to run them automatically with systemd.

Simple startup script

Create a startup script (e.g. ~/valheim_start.sh):

#!/bin/bash
cd /home/valheim/steamcmd/valheim_server
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
./valheim_server.x86_64 -name "MyValheimServer" -port 2456 -world "MyWorld" -password "MySecret" -public 1

Execution:

chmod +x ~/valheim_start.sh
./valheim_start.sh

Important parameters

  • -name: The server name that appears in the list.
  • -port: Default UDP port 2456 (The range 2456–2458 is commonly used).
  • -world: Name of the saved world.
  • -password: Players' password.
  • -public: 1 for public, 0 for private.

Run as a systemd service (automated execution and monitoring)

Use systemd for automation and monitoring. Create the service file:

[Unit]
Description=Valheim Dedicated Server
After=network.target

[Service]
User=valheim
WorkingDirectory=/home/valheim/steamcmd/valheim_server
ExecStart=/home/valheim/valheim_start.sh
Restart=on-failure
RestartSec=10
LimitNOFILE=10000

[Install]
WantedBy=multi-user.target

Activate and run:

sudo systemctl daemon-reload
sudo systemctl enable --now valheim.service
sudo journalctl -u valheim.service -f

Ports, Firewall, and NAT

Port and firewall management is critical for player access and server security.

Required ports

Valheim usually consists of UDP 2456 to 2458 Uses. Open both UDP and TCP to be sure, but at least UDP 2456 should be open. If you are running multiple instances, each instance should have a different port.

Setting up UFW

sudo ufw allow 22/tcp
sudo ufw allow 2456:2458/udp
sudo ufw enable
sudo ufw status

NAT/Port Forwarding

If the server is behind NAT you need to forward UDP 2456 to the internal IP of the server. Cloud servers usually do not have NAT but some VPS may require public port or host network settings.

Backup, storage and world management

Regular backups of the world are essential to prevent data loss.

Game world save path

World files are stored in the following path:

  • ~/.config/unity3d/IronGate/Valheim/worlds

For quick backup:

mkdir -p /home/valheim/backups
tar -czf /home/valheim/backups/world-$(date +%F-%H%M).tar.gz /home/valheim/.config/unity3d/IronGate/Valheim/worlds

You can run this script with cron daily or before an automatic update.

Secure auto-update with SteamCMD

Recommended steps to update without losing data:

  1. Stop the service: sudo systemctl stop valheim.service
  2. Backing up the worlds folder
  3. Run SteamCMD to update (same command +app_update…)
  4. Restart the service

You can create a cron file or systemd timer that automates these steps.

Running with Docker (alternative option)

If you prefer to use containers, you can use the docker-compose example below. The volume is necessary to hold the world.

version: '3.8'
services:
  valheim:
    image: lloesche/valheim-server
    container_name: valheim
    restart: unless-stopped
    ports:
      - "2456:2456/udp"
      - "2457:2457/udp"
      - "2458:2458/udp"
    volumes:
      - ./data:/config
    environment:
      - SERVER_NAME=MyValheimServer
      - SERVER_PORT=2456
      - WORLD_NAME=MyWorld
      - SERVER_PASS=MySecret
      - PUBLIC=1

Tips: Volume is essential for holding the world and run containers with appropriate restart policy.

Performance and resource optimization

Resource optimization includes CPU, memory, and disk to reduce lag and increase stability.

CPU and RAM

Valheim server is a single-threaded mainframe, so a high single-core clock is important. Recommendation: At least 2 high-clocked cores and 4GB of RAM for a small group. For mods and large players, 4 cores and 8+GB of RAM are recommended.

I/O and NVMe

Placing save files (worlds) on NVMe increases save and load speeds. In virtual environments, setting an I/O scheduler such as noob Or mq-deadline It can be useful.

Monitoring

Tools like htop, glances and netstat They are useful for monitoring network resource and packet usage. Monitoring UDP traffic is essential for detecting attacks.

Security and protection (important for public servers)

Server security includes secure execution, restrictions, and protection against network attacks.

Run as non-root

Always run the server with a non-root user (e.g. valheim) Implement to reduce security risks as much as possible.

Limitations and sandbox

Raise limitNOFILE in systemd. Use cgroups to limit resources if needed. Only open necessary ports.

DDoS protection

Using a provider's anti-DDoS service with edge filtering and multiple POPs (85+ locations) can filter malicious traffic before it reaches the server.

Mods, BepInEx and ValheimPlus support

Installing mods usually requires BepInEx. The general installation steps involve copying the BepInEx and ValheimPlus files to the server folder.

Tips for mods

Mods can increase resource usage; at least 4–8 GB of RAM is recommended for a modded server. Be sure to make a full backup of your game world before installing a mod.

Practical tips and common problems

Some common problems and their quick solutions:

  • Players don't see the server list — Check that the UDP ports are open and the parameter -public 1 It is set.
  • Instability and crash — Check the logs; it could be due to low RAM or an incompatible mode.
  • High ping — Choose a data center location close to most players and use a provider with a BGP network.
  • Running multiple instances — Each instance requires a separate port and folder and must be created as a separate unit or container.

Comparing data center locations for online gaming

Choosing a location that suits the distribution of players is very important:

  • Europe (Frankfurt, Amsterdam): Best for European players; low ping and strong network infrastructure.
  • North America (New York, Los Angeles): For players from the US East/West; selection based on player distribution.
  • Asia (Singapore, Tokyo, Sydney): For players from Asia and Oceania; considering the internationality of the players.

A provider with 85+ locations and the ability to choose the nearest POP reduces ping and improves the experience.

Recommended services for hosting Valheim

For the best experience, it is recommended that you use services that have the following specifications:

  • VPS Gaming Server with Dedicated Port and Low Ping
  • Cloud infrastructure with NVMe and high-frequency CPU
  • Active Anti-DDoS option and global network of 85+ locations
  • Ability to quickly upgrade resources, 24/7 support, and quick SteamCMD installation

For a modded server or one with a large number of players, a high-performance cloud server or dedicated server with network services and BGP is recommended.

Frequently Asked Questions

You May Also Like