create valheim server

Jump toUpdate content

Creating a Valheim server with Scaleway

  • compute
  • image
  • gameserver
  • game
  • play
  • Valheim
  • valheim-server
  • Elements

Valheim Server - Overview

Valheim is a survival and sandbox video game that was released in early access on 2 February 2021 for Windows and Linux on Steam. Within only one month after its release the game sold more than 5 million copies and is one of the most played games on Steam.

Players of the game are Vikings in an afterlife where they have to complete missions like crafting tools, building shelters, and fighting enemies to survive. The game has multiple biomes available, such as meadows, swamps, ashlands, mountains, and oceans. Each of these biomes is unique and comes with its own difficulty level - which means players are confronted with different items and enemies. Players can travel through these biomes by either foot or boat. The game supports multiplayer mode with up to ten concurrent players.

At Scaleway, we offer a large range of Instances that will suit the gaming needs of your Valheim server. In this tutorial you will learn how to create your own Valheim server with Scaleway Instances.

Security & Identity (IAM):

You may need certain IAM permissions to carry out some actions described on this page. This means:

  • you are the Owner of the Scaleway Organization in which the actions will be carried out, or
  • you are an IAM user of the Organization, with a policy granting you the necessary permission sets

Deploying an Instance

  1. Click Instances in the Compute section of the Scaleway Console side menu.
  2. Click on Create an Instance and enter the required information for your Instance:
    • The Availability Zone is the geographical region in which your Instance will be deployed. In this tutorial, we use FR-PAR2, but you can choose the one closest to your location.
    • The image that runs on your instance. In this tutorial, we use Ubuntu Focal Fossa (20.04)
    • An Instance Type. It characterizes the performances of your instance. In this tutorial, we use a DEV1-L instance which provides 8GB RAM. If required you can choose a more powerful instance for very large multiplayer sessions.

Click Create Instance to deploy the Instance. You can click on this link to have the instance creation page prefilled with the required information. If you have the Scaleway CLI installed on your computer, you can also use the following command to deploy the instance:

scw instance server create type=DEV1-L zone=fr-par-2 image=ubuntu_focal root-volume=l:80G name=valheim-server ip=new

Installing SteamCMD

  1. Log into your Instance using [SSH](/compute/instances/how(to/connect-to-instance).
  2. The Valheim Server requires SteamCMD, a command line client of the Steam client. It requires the i386 architecture available in the apt package manager. Add it with the following command:
    dpkg --add-architecture i386
  3. Update the apt package repositories and upgrade the software already installed on the machine to the latest version available in Ubuntu’s repositories
    apt update && apt upgrade -y
  4. Install steamcmd and its prerequisites using the apt package manager:
    apt install curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc jq tmux netcat lib32gcc1 lib32stdc++6 steamcmd sudo ufw

Installing the Valheim server


To avoid potential security risks, it is not recommended to run applications under the root account.

  1. Create a new valheim user account using the following command:

    adduser valheim
  2. Add the valheim user to the SuDoers file:

    adduser valheim sudo
  3. Change into the valheim user account:

    su valheim
  4. Change into the users home directory:

    cd ~/
  5. Create a new sub-folder in the users home directory to store the Valheim server files in:

    mkdir valheim-server
  6. Run the following command to download the Valheim server files into the newly created directory using steamcmd:

    steamcmd +login anonymous +force_install_dir /home/valheim/valheim-server +app_update 896660 validate +exit

    The Steam command line tool downloads the latest udpates and installs the Valheim server into our directory. This may take some time. Once completed the following message displays:

    Success! App '896660' fully installed.
  7. Change into the valheim-server directory and make a copy of the start_server.sh script to avoid it being overwritten by an eventual update of Steam:

    cd valheim-server && cp start_server.sh start_valheim_server.sh
  8. Open the script in a text editor, for example nano:

    nano start_valheim_server.sh
  9. Modify the script as follows to download automatically the latest Valheim updates from Steam during the applications’ start. Replace the values My Server with the name of your server, Dedicated with the world you want use on the server, and secret_password with your servers password. Make sure to edit the path of your valheim_server executable to the complete path to the binary file. Once edited, save the file by pressing CTRL+O, then leave nano by pressing CTRL+X.

    export templdpath=$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
    export SteamAppId=892970
    echo "Downloading application updates."
    /home/valheim/.steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/valheim/valheim-server/ +app_update $SteamAppID +quit
    echo "Starting server PRESS CTRL-C to exit"
    # Tip: Make a local copy of this script to avoid it being overwritten by Steam.
    # NOTE: Minimum password length is 5 characters & the password can't be in the server name.
    # NOTE: You need to make sure the ports 2456-2458 are being forwarded to your server through your firewall.
    /home/valheim/valheim-server/valheim_server.x86_64 -name "My server" -port 2456 -world "Dedicated" -password "secret_password"
    export LD_LIBRARY_PATH=$templdpath
    echo "Server started."
  10. Start the Valheim server by running the following command:


Creating a systemd service

Currently we are able to launch the Valheim server manually by connecting using SSH. However after a server reboot it will not start automatically again. We use systemd to automatically launch the Valheim server application after a reboot of our server.

  1. Create a new systemd service file called valheim.service and open it in nano or another text editor of your choice

    sudo touch /etc/systemd/system/valheim.service && sudo nano /etc/systemd/system/valheim.service
  2. Copy and paste the following content into the service file. It tells SystemD to launch the Valheim server automatically during boot once the network is ready:

    Description=Valheim Server Service
    After=syslog.target network-online.target
    ExecStart=/bin/bash /home/valheim/valheim-server/start_valheim_server.sh

    Save the service file by pressing CTRL+O, then leave nano by pressing CTRL+X.

  3. Reload the systemd daemon to make the new service available on the system:

    sudo systemctl daemon-reload
  4. Enable the new service so that it starts automatically upon the next reboot of the instance:

    sudo systemctl enable valheim.service
  5. Start the Valheim Server service:

    sudo systemctl start valheim.service
  6. Wait a few seconds and run the following command to see if the Valheim server runs:

    sudo systemctl status valheim.service

    If ever you want to stop your Valheim server, run the following command:

    sudo systemctl stop valheim.service

Protecting the server

You can configure Uncomplicated Firewall (UFW) to restrict access to our Valheim game server for security reasons. Drop all connections except SSH and the ports of our Valheim server application.

  1. Check the status of the firewall. It should be deactivated before we configure it:

    sudo ufw status
  2. Add the following rules to the configuration:

    sudo ufw deny any
    sudo ufw allow ssh
    sudo ufw allow 2456:2458/udp

    The rules above drop all incoming connections by default, but allow SSH connections and connections to the ports 2456 - 2458, which are used by the Valheim server.

  3. Enable the firewall by running the following command:

    sudo ufw enable


You have now configured your own Valheim server on a Scaleway Instance, installed basic protection through UFW and are ready to invite your friends to explore the different worlds of Valheim. For more information about the game, refer to the official Valheim website.