Prerequisites & VPS Selection
Valheim is a popular survival and exploration game that supports dedicated server hosting for multiplayer gameplay. Running your own server gives you complete control over the game world.
Before starting, ensure you have:
- Ubuntu 22.04 LTS or Debian 12
- Root or sudo access
- Basic familiarity with Linux command line
- Your server name and password decided
Initial Server Setup
Connect to your VPS via SSH and update the system:
sudo apt update && sudo apt upgrade -ysudo apt install -y curl wget tar lib32gcc-s1 software-properties-commonCreate Dedicated User
Never run game servers as root:
sudo useradd -m -s /bin/bash valheim
sudo passwd valheim # Set a passwordInstall SteamCMD
SteamCMD is required to download and update the Valheim dedicated server files.
sudo add-apt-repository multiverse
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y steamcmdInstall Valheim Server
sudo su - valheimmkdir -p ~/valheim-server ~/valheim-data
cd ~/valheim-serversteamcmd +@sSteamCmdForcePlatformType linux +force_install_dir ~/valheim-server +login anonymous +app_update 896660 validate +quit💡 Note: The Valheim dedicated server App ID is 896660. Download takes several minutes depending on your connection speed.
Configure the Server
Create a startup script with your server configuration:
nano ~/start_valheim.sh#!/bin/bash
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970
# Server Configuration
SERVER_NAME="RamNode Valheim Server"
WORLD_NAME="Dedicated"
SERVER_PASSWORD="YourSecurePassword123"
SERVER_PORT=2456
# Start the server
./valheim_server.x86_64 \
-name "$SERVER_NAME" \
-port $SERVER_PORT \
-world "$WORLD_NAME" \
-password "$SERVER_PASSWORD" \
-public 1 \
-savedir ~/valheim-data
export LD_LIBRARY_PATH=$templdpathConfiguration Parameters
-name: Server name in browser-port: Main port (uses 2456-2458)-world: World save file name-password: Min 5 characters-public: 1=public, 0=private-savedir: World saves locationchmod +x ~/start_valheim.shConfigure Firewall
Exit the valheim user and configure firewall rules:
exit # Return to root
sudo ufw allow 2456:2458/udp
sudo ufw allow 22/tcp # Ensure SSH remains accessible
sudo ufw enable
sudo ufw statusPort Requirements
- 2456/UDP: Main game port
- 2457/UDP: Query port
- 2458/UDP: Steam server list port
Systemd Service
sudo nano /etc/systemd/system/valheim.service[Unit]
Description=Valheim Dedicated Server
After=network.target
[Service]
Type=simple
User=valheim
WorkingDirectory=/home/valheim/valheim-server
ExecStart=/home/valheim/start_valheim.sh
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable valheim
sudo systemctl start valheimsudo systemctl status valheim
# View logs
sudo journalctl -u valheim -fServer Management
# Start server
sudo systemctl start valheim
# Stop server
sudo systemctl stop valheim
# Restart server
sudo systemctl restart valheim
# View status
sudo systemctl status valheimUpdate Server
sudo systemctl stop valheim
sudo su - valheim
steamcmd +@sSteamCmdForcePlatformType linux +force_install_dir ~/valheim-server +login anonymous +app_update 896660 validate +quit
exit
sudo systemctl start valheimBackup Strategy
sudo su - valheim
mkdir -p ~/backups
nano ~/backup_valheim.sh#!/bin/bash
BACKUP_DIR=~/backups
DATE=$(date +%Y%m%d_%H%M%S)
tar -czf $BACKUP_DIR/valheim_backup_$DATE.tar.gz ~/valheim-data/
# Keep only last 7 days of backups
find $BACKUP_DIR -name "valheim_backup_*.tar.gz" -mtime +7 -deletechmod +x ~/backup_valheim.sh
crontab -e
# Add this line for daily backup at 4 AM:
0 4 * * * /home/valheim/backup_valheim.shPerformance Optimization
CPU Affinity
sudo systemctl edit valheim
# Add:
[Service]
CPUAffinity=0-1Network Optimization
sudo nano /etc/sysctl.conf
# Add:
net.core.rmem_max=16777216
net.core.wmem_max=16777216
# Apply changes:
sudo sysctl -pMonitor Resources
sudo apt install -y htop iotop nethogs
# Monitor in real-time:
# htop - CPU and memory usage
# iotop - Disk I/O
# nethogs - Network bandwidth per processMods & Admin Configuration
Admin Privileges
sudo su - valheim
nano ~/valheim-data/adminlist.txt
# Add Steam64 IDs of admin players (one per line)BepInEx Mod Support
Popular Valheim mods require BepInEx:
- Download BepInExPack for Valheim from Thunderstore
- Extract to the server directory
- Place mod DLLs in BepInEx/plugins/
- Restart the server
Connecting to Your Server
Method 1: Server Browser
- Open Valheim
- Click "Join Game"
- Search for your server name
- Enter the password
Method 2: Direct Connection
- Press F2 in server browser
- Enter:
your-server-ip:2456 - Click "Connect"
Troubleshooting
Security Best Practices
- • Strong Passwords: Minimum 8 characters with mixed case, numbers, and symbols
- • Keep System Updated: Regular security patches
- • Limit SSH Access: Use SSH keys and disable password authentication
- • Monitor Server Activity: Review logs regularly
- • Regular Backups: Automate world backups to prevent data loss
