How to Self-Host a Valheim Server with Docker

Why Self-Host a Valheim Server?

A self-hosted Valheim server runs 24/7, so your friends can play even when you are offline. Unlike renting from a game server provider, you control world settings, mods, and backups — and you pay nothing beyond the hardware cost. The lloesche/valheim-server Docker image handles SteamCMD, automatic updates, scheduled restarts, and hourly backups out of the box.

Official project: lloesche/valheim-server-docker on GitHub

Prerequisites

  • A Linux server (Ubuntu 22.04+ recommended) with Docker and Docker Compose installed
  • 4 GB of RAM minimum (8 GB recommended)
  • 2+ CPU cores — clock speed matters more than core count for Valheim
  • 5 GB of free disk space (plus world save growth over time)
  • UDP ports 2456-2457 open on your firewall or router (port forwarding guide)

Docker Compose Configuration

services:
  valheim:
    image: ghcr.io/lloesche/valheim-server
    container_name: valheim-server
    cap_add:
      - sys_nice
    ports:
      - "2456-2457:2456-2457/udp"
    environment:
      SERVER_NAME: "My Valheim Server"
      SERVER_PASS: "atleast5chars"
      WORLD_NAME: "MyWorld"
      SERVER_PUBLIC: "false"
      TZ: "America/New_York"
      UPDATE_CRON: "*/15 * * * *"
      UPDATE_IF_IDLE: "true"
      RESTART_CRON: "0 5 * * *"
      RESTART_IF_IDLE: "true"
      BACKUPS: "true"
      BACKUPS_CRON: "0 * * * *"
      BACKUPS_ZIP: "true"
      BACKUPS_MAX_AGE: "3"
    volumes:
      - ./valheim-config:/config
      - ./valheim-data:/opt/valheim
    restart: unless-stopped
    stop_grace_period: 120s

Key configuration:

VariablePurpose
SERVER_NAMEName displayed in the server browser
SERVER_PASSLogin password — minimum 5 characters, required
WORLD_NAMEWorld name (without file extension). Changing this creates a new world.
SERVER_PUBLICtrue lists the server in the browser. false makes it private (join by IP).
cap_add: sys_niceAllows the container to set process priority for better performance
stop_grace_period: 120sGives the server time to save the world before Docker kills it

Start the server:

docker compose up -d

First startup takes 5-10 minutes while SteamCMD downloads Valheim server files (~1 GB). Watch progress with:

docker compose logs -f valheim

The server is ready when you see Game server connected.

Connecting to Your Server

From Valheim:

  1. Click Join GameAdd Server
  2. Enter your-server-ip:2456
  3. Enter the password you set in SERVER_PASS

For LAN play, use the server’s local IP. For internet play, forward UDP ports 2456-2457 on your router. Alternatively, use Tailscale for zero-config access without port forwarding.

Automatic Updates and Restarts

The image checks for Valheim updates every 15 minutes by default. When an update is available and no players are online (if UPDATE_IF_IDLE is true), it downloads and installs the update automatically.

SettingDefaultWhat It Does
UPDATE_CRON*/15 * * * *How often to check for updates
UPDATE_IF_IDLEtrueOnly update when no players are connected
RESTART_CRON10 5 * * *Daily server restart schedule
RESTART_IF_IDLEtrueOnly restart when no players are connected

To disable automatic updates entirely, set UPDATE_CRON: "".

Backups

Backups are enabled by default. The image creates compressed world backups every hour and cleans up backups older than 3 days.

SettingDefaultPurpose
BACKUPStrueEnable/disable automatic backups
BACKUPS_CRON5 * * * *Backup schedule (hourly at minute 5)
BACKUPS_ZIPtrueCompress backups to save disk space
BACKUPS_MAX_AGE3Days to keep backups before auto-deletion
BACKUPS_IF_IDLEtrueBackup even when no players are online

Backups are stored in /config/backups/ inside the container (mapped to ./valheim-config/backups/ on the host).

To restore a backup:

docker compose down
cd valheim-config/backups/
# Unzip the desired backup
unzip backup-YYYYMMDD-HHMMSS.zip -d ../worlds_local/
docker compose up -d

For additional backup strategies, see our backup guide.

Crossplay (Xbox/PC Game Pass)

To allow non-Steam clients (Xbox, PC Game Pass) to connect:

environment:
  SERVER_ARGS: "-crossplay"

Add port 2458 to your port mappings:

ports:
  - "2456-2458:2456-2458/udp"

Crossplay uses PlayFab instead of Steam networking. Both Steam and non-Steam players can connect simultaneously when crossplay is enabled.

Admin Controls

Adding Admins

Set admin SteamID64s via environment variable:

environment:
  ADMINLIST_IDS: "76561198012345678 76561198087654321"

Find your SteamID64 at steamid.io.

Banning Players

environment:
  BANNEDLIST_IDS: "76561198099999999"

Allowlist Mode

Restrict access to specific players only:

environment:
  PERMITTEDLIST_IDS: "76561198012345678 76561198087654321"

When PERMITTEDLIST_IDS is set, only those SteamID64s can join the server.

BepInEx Mods

To enable BepInEx modding framework:

environment:
  BEPINEX: "true"

The BepInEx framework installs automatically on next restart. Place mod DLLs in ./valheim-config/bepinex/plugins/:

cp my-valheim-mod.dll ./valheim-config/bepinex/plugins/
docker compose restart valheim

Note: BepInEx and ValheimPlus are mutually exclusive. BepInEx is the more actively maintained framework and supports most mods on Thunderstore.

Troubleshooting

Server Does Not Appear in Browser

Symptom: SERVER_PUBLIC: "true" but the server is not listed.

Fix:

  • Wait 10-15 minutes after startup — Steam registration can be slow
  • Verify UDP ports 2456-2457 are forwarded and reachable
  • Connect directly by IP (your-ip:2456) instead of using the browser
  • Check docker compose logs valheim for Steam registration errors

Players Get Disconnected Frequently

Symptom: Players kicked with “Disconnected” after a few minutes.

Fix:

  • Ensure SERVER_PASS is at least 5 characters
  • Check server RAM usage — Valheim needs 4+ GB free
  • Verify the host’s network is stable (packet loss causes disconnects)
  • If using crossplay, ensure port 2458/udp is also forwarded

World Save Corruption

Symptom: Server starts with a fresh world despite existing saves.

Fix:

  • Check that WORLD_NAME matches exactly (case-sensitive)
  • Verify ./valheim-config/worlds_local/ contains your .db and .fwl files
  • Restore from the latest backup in ./valheim-config/backups/
  • Never use docker compose down -v — this deletes volumes and world data

Resource Requirements

PlayersRAMCPUDisk
1-34 GB2 cores5 GB
4-66 GB2-4 cores10 GB
7-108 GB4 cores15 GB
10+8-12 GB4 cores (high clock)20+ GB

Valheim is CPU-bound. A 4-core CPU at 4.0 GHz will perform noticeably better than an 8-core at 2.5 GHz. If you experience tick lag with many players, prioritize clock speed.

Idle server RAM usage is approximately 2.8 GB, with each connected player adding 100-200 MB.

Verdict

The lloesche/valheim-server image is the best way to run a Valheim dedicated server. Built-in automatic updates, scheduled backups, and graceful shutdown handling mean the server mostly runs itself. BepInEx support covers the modding ecosystem. The only downside is that the image uses rolling tags rather than semantic versions — pin to a specific SHA if you need exact reproducibility.

For managing multiple game servers including Valheim, look at Pterodactyl or Crafty Controller.

Comments