GamingPH.com

How to Set up Valheim Dedicated Server using DigitalOcean or Vultr

Ever wonder how to setup a Valheim dedicated server using cloud VPS? like the popular cloud hosting DigitalOcean and Vultr? Creating your own Valheim dedicated server allows you to take control of your world and players.

As of May 23, 2023, we have updated this article to ensure it is working on the latest version of Valheim and the latest version of Ubuntu OS 22.10 x64.

Table of Contents

  1. Sign-up for a Cloud Server
    1. How to Create Digital Ocean Droplet
    2. How to Create Vultr Server
  2. Setting up Valheim Server
  3. How to connect to your Valheim Dedicated Server
  4. Assign Admin access to your Character
  5. How to Backup and Restore Server World Data
  6. How to update your Valheim Dedicated Server
  7. Firewall for Security
    1. DigitalOcean Firewall
    2. Vultr Firewall

In this guide, we will teach you how to setup your own dedicated server for Valheim – from scratch to complete and without using any third party scripts. Good for newbies who has literally no idea about servers and wanted to learn this stuff. This is a step-by-step guide so you can follow each step.

Sign-up for a Cloud Server

First you need a hosting cloud server, you can use either DigitalOcean or Vultr. If you don’t have one, you can sign up below to get free $100 credits.

The Valheim server will require atleast 2GB of RAM and 10% of CPU usage. With this, you need to pick a droplet (Digital Ocean) or a product (Vultr) that meet the minimum specs.

There are two type of cloud servers. First, shared server which means the CPU and Memory resources that you’re not currently using are shared with other users in that particular server. Dedicated server on the other hand means you solely use all of the CPU and Memory resources, getting rid of noisy neighbor, good for server who constantly uses 50 to 100% CPU loads.

How to Create Digital Ocean Droplet

To create a droplet, click the Create > Droplets at the top corner of the page. For the Region, you need to select the nearest region you want your player to play. The closest gives you faster ping – means better gameplay. For example, we are in the Philippines, the closest server is Singapore.

For Choose an image, select the latest Ubuntu version, the 22.10 x64.

For the Size, the cheaper plan is the Shared CPU and lowest plan that has 2GB memory are the following: You may also pick higher specs to accommodate more players depending on your budget. The Bandwidth is the download/upload

ServerSpecs
Shared Regular
$12 per month
1 CPU
2GB Memory
50GB SSD Disk
2TB Bandwidth
Shared Premium Intel
$14 per month
1 Intel CPU
2GB Memory
50GB NVMe SSD Disk
2TB Bandwidth
Shared Premium AMD
$14 per month
1 AMD CPU
2GB Memory
50GB NVMe SSD Disk
2TB Bandwidth
General Purpose
$63 per month
2 CPU
8GB Memory
25GB SSD Disk
4TB Bandwidth
CPU-Optimized Regular
$42 per month
2 CPU
4GB Memory
25GB SSD Disk
4TB Bandwidth
CPU-Optimized Premium Intel
$109 per month
4 CPU
8GB Memory
50GB SSD Disk
5TB Bandwidth
Memory-Optimized
$84 per month
2 CPU
16GB Memory
50GB SSD Disk
4TB Bandwidth
Storage-Optimized Regular
$131 per month
2 CPU
16GB Memory
300GB NVMe SSD Disk
4TB Bandwidth

For the authentication, to make it straight-forward, select Password. From here, you need to enter the root password.

You may also customize the hostname of your droplet or leave it as is. Once, done you can now click Create Droplet.

It will take time to create the droplet, once completed you will be able to get its IP Address. You will need this to access your server through a command prompt.

How to Create Vultr Server

For Vultr, to deploy a server go to the Products page then click the blue + button at the right corner of the page, click Deploy New Server.

From here, pick the type of server you want, below are the list of minimum specs that you can choose, you may also pick higher specs. You must also pick a server location that are nearest to you for lower ping.

ServerTypeSpecs
Cloud Compute
$10 per month
Shared1 CPU
2GB Memory
2TB Bandwidth
55GB SSD Storage
High Frequency
$12 per month
Shared1 CPU
2GB Memory
2TB Bandwidth
64GB NVMe SSD Storage
Dedicated Cloud
$60 per month
Dedicated2 CPUs
8GB Memory
10TB Bandwidth
120GB SSD Storage

For Server Type, make sure to pick Ubuntu 22.10 x64. Then enter your root Password, your Server Hostname and Label. Once done, click Deploy Now.

Setting up Valheim Server

To open up your server, we need to use the Command Prompt (CMD) which has a built-in SSH command for Windows 11. Make sure you already have the public IP Address of the server you have created from Digital Ocean or Vultr server. Then run this command, make sure to enter the correct server password you have choose while creating the server:

ssh root@YOUR_SERVER_IPADDRESS

You will then be able to enter your server. Now, we have to install some important library into our server that will allows us to install the Steam SDK.

sudo dpkg --add-architecture i386

After that, we can now update and upgrade our server to the latest packages. If it asked for a confirmation, just type -y then press Enter in your keyboard.

sudo apt update && sudo apt upgrade -y

While updating, there might some files that requires for an update. For this case, just select the default values. Like for Configuring openssh-server, just select the default value “Keep the local version currently installed” and for Pending Kernel upgrade, just select OK, “cron.service”, etc..

(Optional) For those who wants to enable cross play, allowing console players to join in the server. You need to install additional libraries (Thanks to Gregory for this guide)

sudo apt-get install libpulse0 libpulse-dev libatomic1 libc6 -y

Once our server is fully updated, we can then install the Steam SDK:

sudo apt-get install steamcmd -y

To accept the terms and condition, press the right arrow keys to select <OK>, then press Enter.

Then select, I AGREE and press Enter. If it asked for package update, just select the default values.

To safeguard our server, we need to create a new user called “steam” that will run exclusively our Valheim server without using the root access (sudo). To create a user, just run this command and enter a password. When asked for Full name, just input Steam and leave other details blank.

sudo adduser steam

Now that we have created the steam user in our server, we can now logout our root access.

exit

Installing Valheim Server

We have now setup our server and created a steam user. We can now install the Valheim in our server. Login back to the server again, but this time using the steam user.

ssh steam@YOUR_SERVER_IPADDRESS

We then need to create a symbolic link for our SteamCMD command.

ln -s /usr/games/steamcmd steamcmd

and create a folder for our Valheim server files inside the steam directory.

mkdir /home/steam/valheim

We will now the download and install the Valheim server, this will take time some minutes to complete (3 to 10 minutes). If you received an error ILocalized::Addfile() failed to load file “public/steambootstrapper_english.txt”, just ignore it.

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

After that, we need to set up a separate configuration file because the default default configuration start_server.sh are being replaced with default file by Steam every time our server is loaded erasing our own configuration. To avoid this from happening, we will be using start_valheim.sh instead.

cp /home/steam/valheim/start_server.sh /home/steam/valheim/start_valheim.sh

Let’s edit the file start_valheim.sh with VIM. For those who are new to VIM, it is a text editor for command prompt.

vim /home/steam/valheim/start_valheim.sh

To use VIM, press I to enter the insert mode which allows you to edit the file just like a notepad. In case you accidentally enter other mode, just press ESC.

Then change the file with this configuration. Don’t forget to change the place holders:

(If you want to copy and paste the text above, to paste on VIM, make sure you’re in INSERT mode – press right click on your mouse).

#!/bin/bash
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

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 & Password cant be in the server name.
# NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.
./valheim_server.x86_64 -name "YOUR_VALHEIM_SERVERNAME" -port 2456 -nographics -batchmode -world "YOUR_WORLD_NAME" -password "YOUR_PASSWORD" -public 1

export LD_LIBRARY_PATH=$templdpath

(Optional) If you want to enable crossplay, just add -crossplay in the line ./valheim_server.x86_64. It should look like:

./valheim_server.x86_64 -name "YOUR_VALHEIM_SERVERNAME" -port 2456 -nographics -batchmode -world "YOUR_WORLD_NAME" -password "YOUR_PASSWORD" -public 1 -crossplay

Here are some explaination on server configuration:

After that, press ESC from your keyboard then type !wq to exit and save the text editor.

Run the Valheim Server

Since we already installed the steam files, we can now go back to our root user and apply important file permission. To gain root access, just type the commands below. You then need to enter your server’s password.

su -

In order for start_valheim.sh to be executable, we need to add permission on it.

chmod +x /home/steam/valheim/start_valheim.sh

From here, you can already start running the server – if you wish to test it (This is optional, we recommend completing the other step before running to save time – to close the running program, just press CTRL + C):

cd /home/steam/valheim
./start_valheim.sh

To run our Valheim server on startup, we have to add it to the service, create a file called valheim.service inside the system directory.

vim /lib/systemd/system/valheim.service

Now, add these codes. Press I from your keyboard to enter Insert mode and paste the following text (To paste in vim, right-click on mouse). To save and exit, press ESC then type wq! to exit the text editor.

[Unit]
Description=Valheim Server

[Service]
User=steam
WorkingDirectory=/home/steam/valheim
Type=simple
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
User=steam
Group=steam
ExecStartPre=/home/steam/steamcmd +login anonymous +force_install_dir /home/steam/valheim +app_update 896660 validate +exit
ExecStart=/home/steam/valheim/start_valheim.sh
ExecStop=/bin/killall -TERM valheim_server
LimitNOFILE=100000

[Install]
WantedBy=multi-user.target

After that we have to reload our daemon to reflect the changes. Then enable valheim at startup. Lastly, run our server for the first time.

systemctl daemon-reload
systemctl enable valheim.service
systemctl start valheim

To check if its running, use this command to check it’s status. It will take time to initialize the server about (1 to 2 minutes). When you see the message “Game server connected”, this means it is completed and your player can connect now to the server.

watch systemctl status valheim

Here are the important commands that you can use in case you encounter some problem halfway.

If you got an error, you can enter journalctl -e then paste the log on the comment section below so we can help you troubleshoot for any problem.

You can also check our separate guide on setting up Domain Name for Valheim Dedicated Server, which allows you to join the server with memorable words instead of IP addresses.

How to connect to our Valheim Dedicated Server

We have now a working server, what else we need to do is on how to connect into our server. For us to invite our friends to join and play together. Open up Valheim, then click the Start button.

Click the Join Game tab, then at the bottom select the option Community, then press Join IP.

Enter your server’s ip address with these format:

YOUR_IPADDRESS:2456

Wait until it is connected and enter the server password to connect to the game.

If your server is not listed on the Community tab, there are some reason why it is not listed. First, the server is not near your region. For example, if you’re in the Philippines and your server is in United States, players in SouthEast Asia region will not able to see your server at the Community tab. But if your server is located in SEA region like Singapore, Japan, Hong-Kong or Philippines, you server will be listed for players in that region.

Assign Admin access to your Character

To give you complete control not just on your server but as well as in the game, you can assign your Valheim account character as an admin on it. You simply need to the Steam ID in the file adminlist.txt.

You can find your SteamID in-game, as well as for other player by pressing F2. The UID on the players list is the Steam ID of that player.

Since you already have the SteamID you can then add it on the adminlist text.

vim ~/.config/unity3d/IronGate/Valheim/adminlist.txt

In the vim text editor, just add the Steam ID at the bottom. Save the file !wq. Don’t forget to restart your server.

systemctl restart valheim

To use your admin control, in-game just press F5 and you can execute the following command as admin.

Update: The admin access is not yet available on the game. To banned users, you need to manually add it on bannedlist.txt and adminlist.txt.

How to back up and restore World Server Data

Just like the client side where your map data is located on users directory. For server side, it keeps on the default directory ~/.config/unity3d/IronGate/Valheim.

If you want to back up these file into your computer or transfer it to other server. You can use scp command to copy it. (Note: the CMD must not be connected from your server. To make sure you’re not connected, open up a new Command Prompt)

First, we need to create a folder into your computer. Or you can skip this and use your existing folder.

mkdir C:\YOUR_FOLDER_BACKUP

We can then download the file and transfer it directly into your computer.

scp -r root@YOUR_SERVER_IPADDRESS:/home/steam/.config/unity3d/IronGate C:\YOUR_FOLDER_BACKUP

To restore the data, first we need to stop our server first. You need to login into your server.

ssh root@YOUR_SERVER_IPADDRESS

Then run the stop server command. Then exit from your server.

systemctl stop valheim
exit

Then just interchange the path on our backup command. This will automatically transfer all files from your backup folder directly to your server’s world data.

scp -r C:\YOUR_FOLDER_BACKUP root@YOUR_SERVER_IPADDRESS:/home/steam/.config/unity3d/IronGate

Don’t forget to start your valheim to see the restored world data.

ssh root@YOUR_SERVER_IPADDRESS
systemctl start valheim

How to Update Valheim Dedicated Server

For maintenance and updates, it is also important to make your server up to date incase Valheim will drop a huge update into the game. To update to the latest version, simply run the following commands.

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

Do not forget to restart your server after the update installation is completed.

systemctl restart valheim

Firewall for Security

To protect your server from unwanted attempted login or brute force. You can enable a firewall into your server.

DigitalOcean and Vultr has a firewall web interface directly from their dashboard. You can then attached this firewall into your server. If you’re using your Valheim server as a game server only, we just need to enable access to the UDP port 2456-2458 for our server to work. Other port is not needed except for port 22 for SSH.

DigitalOcean Firewall

For DigitalOcean, go to Manage > Networking > Firewalls. Then press the Create Firewall button.

At Inbound Rules, click the new rule dropdown menu and select Custom. It will then populate the other settings, select UDP as Protocol, then at the Port Range enter 2456-2458. (Optional) You may also restrict other IP addresses to access your SSH server. This is by removing All IPv4 and All IPv6 at the SSH Sources. Then enter your public IP address on it.

At the Apply to Droplets, search and select your Droplet Server. Then click the Create Firewall to apply the firewall.

Vultr Firewall

For Vultr, go to Products > Firewall. Then hover the + and click Add Firewall Group. Name your firewall and click the Add Firewall Group button.

At the IPv4 Rules, we have to give access first to our SSH server, the default value is for SSH, just press + to add it. (Optional) You can also restrict access to your SSH server exclusively to your IP address only. To do that, at Sources, just click My IP then press + to apply.

At the IPv4 Rules, there should be a dropdown from the list where you can add a new rule. Click the dropdown for Protocol and select UDP, at Port (or range) enter 2456-2458 then click the + button.

To apply it into your server, go to the Products > Instances then click your Server. Then at Settings > Firewall. From the dropdown menu select the Firewall that you just created. Then click Update Firewall Group to complete.

The changes will take effect within 120 seconds.

Troubleshooting

If you received an error saying Failed to start Valheim just like below, you need to make sure that the path names and spelling are correct in both start_valheim.sh and /lib/systemd/system/valheim.service.

× valheim.service - Valheim Server
     Loaded: loaded (/lib/systemd/system/valheim.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2023-05-23 02:35:18 UTC; 1min 27s ago
   Duration: 9ms
    Process: 22726 ExecStartPre=/home/steam/steamcmd +login anonymous +force_install_dir /home/steam/valheim +app_update 896660 validate +ex>
    Process: 22747 ExecStart=/home/steam/valheim/start_valheim.sh (code=exited, status=2)
   Main PID: 22747 (code=exited, status=2)
        CPU: 5.892s

May 23 02:35:13 ubuntu-valheim systemd[1]: valheim.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
May 23 02:35:13 ubuntu-valheim systemd[1]: valheim.service: Failed with result 'exit-code'.
May 23 02:35:13 ubuntu-valheim systemd[1]: valheim.service: Consumed 5.892s CPU time.
May 23 02:35:18 ubuntu-valheim systemd[1]: valheim.service: Scheduled restart job, restart counter is at 1.
May 23 02:35:18 ubuntu-valheim systemd[1]: Stopped Valheim Server.
May 23 02:35:18 ubuntu-valheim systemd[1]: valheim.service: Consumed 5.892s CPU time.
May 23 02:35:18 ubuntu-valheim systemd[1]: valheim.service: Start request repeated too quickly.
May 23 02:35:18 ubuntu-valheim systemd[1]: valheim.service: Failed with result 'exit-code'.
May 23 02:35:18 ubuntu-valheim systemd[1]: Failed to start Valheim Server.
Exit mobile version