Valheim is a new "brutal exploration and survival game" that is "set in a procedurally-generated purgatory inspired by viking culture". This is a guide on how to run your own dedicated Valheim server.

Requirements
A Digital Ocean droplet with at least 2 vCPUs and 4Gb of Memory (or equivalent) is necessary in order to support 10 concurrent players (currently the games maximum).
Use my Digital Ocean referral link to receive $100 in credit (that's 5 free months to run this server!): https://m.do.co/c/1f8474f4a7c7
Getting started
Once you've got your server provisioned you can follow these dedicated server installation instructions to install and run the Valheim dedicated server binary.
One of the last steps will have you expose traffic to UDP ports on your server so game clients can connect. Here's how you can do this on a Digital Ocean droplet running Ubuntu:
sudo ufw allow ssh
sudo ufw allow 2456:2458/udp
printf 'y' | sudo ufw enable
Don't skip the first command in the block above, otherwise you'll lock yourself out of your server via SSH.
Connecting
Once your server has been rebooted you can now connect with a game client and invite your friends to do the same. Be sure to give them the following:
- The server name (Incase they want to search via the in-game interface)
- The server IP address (Incase they want to connect directly via IP)
- The server password (If you setup a private server rather than public)
Admin access
Want to grant your friends in-game admin access to the server?
Find your friends Steam ID and append it to this file:
echo "${STEAM_ID}" >> /home/steam/.config/unity3d/IronGate/Valheim/adminlist.txt
Backups
If something happens to your server you definitely don't want to lose all the time and effort you and your friends have put into your world. Luckily you can use a few readily available tools to backup your world data in order to prevent this scenario.
You could always backup your world data by using scp
to copy the /home/steam/.config/unity3d/IronGate/Valheim/worlds
directory to some other machine, but if you want to bullet-proof this you should archive these backups in the cloud.
Assuming you've got an AWS account and an S3 bucket, first wire up the credentials on your server:
cat << EOF > /etc/environment
AWS_DEFAULT_REGION=us-west-2
AWS_ACCESS_KEY_ID=redacted
AWS_SECRET_ACCESS_KEY=redacted
S3_BUCKET_NAME=redacted
EOF
Here's how to backup your world data to S3 using tar
and gzip
:
tar c /home/steam/.config/unity3d/IronGate/Valheim/worlds | gzip | aws s3 cp - s3://${S3_BUCKET_NAME}/$(date +%Y-%m-%d-%H.%M.%S).tar.gz
If you want to automate this just add the command above to your crontab
:
sudo apt install cron
sudo systemctl enable cron
crontab -l | { cat; echo "@daily tar c /home/steam/.config/unity3d/IronGate/Valheim/worlds | gzip | aws s3 cp - s3://${S3_BUCKET_NAME}/$(date +%Y-%m-%d-%H.%M.%S).tar.gz"; } | crontab -
Upgrades
Luckily the scripts included in the dedicated server installation instructions handle upgrades automatically, however the valheimserver.service
needs to be restarted via systemctl
each time there is a client release. This can be especially annoying when you wake up to a slew of messages from your fellow vikings when they can't connect to your server.
Here's how to manually restart your Valheim server:
sudo systemctl stop valheimserver.service && \
sleep 60 && \
sudo systemctl start valheimserver.service