How to Set up Valheim Dedicated Server using DigitalOcean or Vultr

Written by

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.

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

For DigitalOcean, to create a droplet click the Create > Droplets at the top corner of the page.

At Choose an image, to use the commands in our guides, we need to use Ubuntu 20.04 (LTS) x64. At Choose a plan, pick your server specs that you want to use, below are the minimum specs that you can try (You may also pick higher specs than below if your budget is not an issue).

ServerTypeSpecs
Shared CPU
$10 per month
Shared1 CPU
2GB Memory
2TB Bandwidth
55GB SSD Storage
Shared CPU (Premium Intel or AMD)
$12 per month
Shared1 AMD/Intel CPU
2GB Memory
2TB Bandwidth
50GB NVMe SSD Storage
General Purpose
$60 per month
Dedicated2 CPUs
8GB Memory
4TB Bandwidth
25GB SSD Storage
CPU-Optimized
$40 per month
Dedicated2 CPUs
4GB Memory
4TB Bandwidth
25GB SSD Storage
Memory-Optimized
$40 per month
Dedicated2 CPUs
16GB Memory
4TB Bandwidth
50GB SSD Storage
Storage-Optimized
$125 per month
Dedicated2 CPUs
16GB Memory
4TB Bandwidth
300GB NVMe SSD Storage

In the datacenter, it is ideal to choose the nearest region for lower ping (For example, if you’re in the Philippines, the nearest datacenter is Singapore).

For authentication, select password. Then enter the password that you want to use for root user every time you access it. You may also rename your hostname and add a tags if you’d like. Once everything is fine, click Create Droplet.

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 20.04 x64. Then enter your root Password, your Server Hostname and Label. Once done, click Deploy Now.

Setting up Valheim Server

Open up your command prompt (CMD) and we will be using the built-in Windows 10 SSH command to enter to the server that you just created. Go to your cloud server dashboard and get the public IP address of it and enter the following command in the CMD. You also need to enter the root password that you use in creating your droplet/vultr server.

ssh root@YOUR_SERVER_IPADDRESS

Now, we have to add the i386 libraries into our server. This will allow us to install Steam SDK.

sudo dpkg --add-architecture i386

Afterwards, you need to update and upgrade your server to the latest packages which will also includes our Steam SDK’s. If it asked for another confirmation, just type -y then press enter in your keyboard.

sudo apt update && sudo apt upgrade -y

Now, install our steam SDK using this command.

sudo apt-get install steamcmd -y

To have a safe environment incase someone was able to enter your server, we need to create an exclusive user intended for Valheim steam server only. Which will avoid them from running executable files using root (sudu). Once you’ve created a user, it will asked you to enter a new password for steam, make sure to type a strong password to protect your server. (for Full Name, just add Steam and leave blank to other details)

sudo adduser steam

Now, we will logout as a root user.

exit

Login back to your server again, but this time as a steam user.

ssh steam@YOUR_SERVER_IPADDRESS

Make sure we are in the same home directory.

cd ~

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

ln -s /usr/games/steamcmd steamcmd

Then we will create a folder for our Valheim inside 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).

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

After installing the Valheim server, we need to set up a configuration file. The default configuration which is start_server.sh are being replaced with default information by Steam every time our server is loaded. So, we need to create a new copy that contains our own configurations, we will use start_valheim.sh instead.

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

We then need to edit the start_valheim.sh file with VIM. If its your first time to use this text editor, once you’ve enter the command below. You need to press I to enter insert mode which allows you to edit the file like just a notepad. In case it automatically starts at Replace Mode, just press ESC and press I again.

vim /home/steam/valheim/start_valheim.sh

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

  • YOUR_VALHEIM_SERVER_NAME – This will be the name that will appear on the Community Server list in Valheim.
  • YOUR_WORLD_NAME – Generated maps will depends on this name.
  • YOUR_PASSWORD – Password to your Valheim server, this is the password that you’ll give to other players in order for them to join.
#!/bin/sh
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/steam/valheim/linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

echo $LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH


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.
/home/steam/valheim/valheim_server.x86_64 -name "YOUR_VALHEIM_SERVER_NAME" -port 2456 -world "YOUR_WORLD_NAME" -password "YOUR_PASSWORD" -batchmode -nographics

export LD_LIBRARY_PATH=$templdpath

The additional configuration -batchmode and -nographics will allow your server to run without additional UI or graphics, this will save you more memory and processes since we’re only running our server on the background. After enabling this, our memory usage reduces to half.

After editing, press ESC from your keyboard then type !wq to exit and save the text editor. (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).

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

The last touch we need to do is to run the Valheim server in start up. To do that, we have to add it at the services. We have to create a new 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]
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.

systemctl status valheim

Here are important command that you can use incase you encounter some problem half way.

  • systemctl start valheim – Start the Valheim Server.
  • systemctl stop valheim – Stop the Valheim Server from running.
  • systemctl restart valheim – Restart the Valheim Server, useful when you do changes on the settings.

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.

To find your Steam ID, simply open a browser and go to your Steam Profile page (eg https://steamcommunity.com/id/GamingPH_com), right click the page and click View Source. Search and find this string g_rgProfileData =. The numeric value of “steamid” is your ID.

Alternatively, you can also find your SteamID in-game, as well as for other player by pressing F2. The ID 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.

  • kick [name/ip/userID] – ban player
  • ban [name/ip/userID] – ban player
  • unban [ip/userID] – unban player
  • banned – List of all banned players

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.

Article Tags:
Article Categories:
Guide · How To

Comments

  • David FAIVRE-MAÇON March 27, 2021 1:09 pm

    thanks, great article, but my server often restarts, any idea? it’s a digitalOcean droplet 1cpu, 2go, even when I play alone it retarts

    Reply
    • Erwin Bantilan March 27, 2021 11:43 pm

      Hi David,

      can you send us the information when you enter this command: journalctl -e

      Reply
  • David FAIVRE-MAÇON March 28, 2021 10:31 pm

    sorry, i’m upgrade my server to 2cpu and 4go, it works now…

    Reply
  • SplunkyGamer April 29, 2021 3:25 pm

    root@ValheimDroplet:~# systemctl stop valheim
    root@ValheimDroplet:~# systemctl start valheim
    root@ValheimDroplet:~# systemctl status valheim
    ● valheim.service – Valheim Server
    Loaded: loaded (/lib/systemd/system/valheim.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Thu 2021-04-29 15:23:27 UTC; 1min 10s ago
    Process: 37017 ExecStartPre=/home/steam/steamcmd +login anonymous +force_install_dir /home/steam/valheim +app_updat>
    Process: 37050 ExecStart=/home/steam/valheim/start_valheim.sh (code=exited, status=203/EXEC)
    Main PID: 37050 (code=exited, status=203/EXEC)

    Apr 29 15:23:27 ValheimDroplet systemd[1]: valheim.service: Scheduled restart job, restart counter is at 3.
    Apr 29 15:23:27 ValheimDroplet systemd[1]: Stopped Valheim Server.
    Apr 29 15:23:27 ValheimDroplet systemd[1]: valheim.service: Start request repeated too quickly.
    Apr 29 15:23:27 ValheimDroplet systemd[1]: valheim.service: Failed with result ‘exit-code’.
    Apr 29 15:23:27 ValheimDroplet systemd[1]: Failed to start Valheim Server.

    not sure why its failing

    Reply
  • SplunkyGamer April 29, 2021 6:10 pm

    ● valheim.service – Valheim Server
    Loaded: loaded (/lib/systemd/system/valheim.service; enabled; vendor preset: enabled)
    Active: active (running) since Thu 2021-04-29 18:00:12 UTC; 7min ago
    Process: 38630 ExecStartPre=/home/steam/steamcmd +login anonymous +force_install_dir /home/steam/ValheimDedicatedSe>
    Main PID: 38668 (start_valheim.s)
    Tasks: 24 (limit: 1137)
    Memory: 606.1M
    CGroup: /system.slice/valheim.service
    ├─38668 /bin/sh /home/steam/ValheimDedicatedServer/start_valheim.sh
    └─38669 /home/steam/ValheimDedicatedServer/valheim_server.x86_64 -name SplunkyGod -port 2456 -world Algaro>

    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: NullGfxDevice:
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: Version: NULL 1.0 [1.0]
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: Renderer: Null Device
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: Vendor: Unity Technologies
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: Begin MonoManager ReloadAssembly
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: – Completed reload, in 0.139 seconds
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: UnloadTime: 2.749268 ms
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: 04/29/2021 18:00:12: Starting to load scene:start
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]:
    Apr 29 18:00:12 ValheimDroplet start_valheim.sh[38669]: (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

    Its seems like I got the status fail issue sorted, I had just copy pasted what was given in this article I had to jsut change my actual path which was ValheimDedicatedServer.

    My problem now is it doesnt connect to the server, it shows fail to connect popup and when I check the player logs it shows

    Got problem 5003:Timed out attempting to connect

    got it from player.log

    Reply
  • SplunkyGamer April 30, 2021 6:33 am

    I just checked its getting restarted, 1cpu and 1gb wont work on this. hmmm, 2 cpu and 4gb seems expensive to me. I would rather setup a raspberry pi 4 and do port forwarding to it to get it working I guess. This article really was helpful. Thanks Guys.
    Anybody setting it up u will need to config mentioned by David FAIVRE-MAÇON. It should work flawlessly with that.

    Reply

Leave a Reply to Erwin Bantilan Cancel reply