Valheim is an incredible co-op game. For the best co-op Valheim experience, you should play on a dedicated server. Dedicated servers have many advantages, for example:
- Performance: you might not notice it at first, but as you progress in the game, hosting and playing at the same time can cause you to lag, sometimes at the worst possible moment.
- Always on: if you are playing with two or more friends, it might be challenging for everyone to log on at the same time. A dedicated server is always available so you and you friends can log on any time.
- Latency: if your friends live far away, a dedicated server can split the latency difference and provide a better overall experience to everyone.
If you already have a Linux instance, feel free to skip to the next section.
How to Create a Linux Instance
I'm using Amazon Lightsail because of the flat pricing, performance, and ease-of-use.
- You will need an AWS account. If you don't have one, click here to sign up.
- Open the Amazon Lightsail console.
- Click "Create instance":
Click "Change AWS Region and Availability Zone":
Choose a region in which to launch your server. The closer to you, the lower latency you will get while playing. But don't forget to consider where your friends are connecting from!
Under "Pick your instance image", choose Linux/Unix, OS Only, Ubuntu 20.04
Choose the 4GB RAM instance type or higher:
Give your instance a name and then click "Create Instance"
Note: if you are using a brand new AWS account, you might not be able to successfully launch your instance. If this happens, wait for a few minutes; you should receive an email indicating that your account was successfully verified.
Once your server is up, click the "..." icon and then click "manage":
Valheim uses several UDP ports for communication, so we need to configure the firewall rules on our instance. Click the "Networking" tab, the click "Add Rule":
Enter the rule like the screenshot below:
Click "Create" to save the firewall rule, then click the "Connect" tab and click "Connect using SSH". This page also has instructions on how to use your own SSH client if you prefer.
Once connected, you should see a browser window like so:
Now you're ready to install and run the Valheim server.
How to run a Valheim server on Linux:
We will be running Valheim using docker. First, install docker:
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo apt install docker-compose
Next, we will create the
curl -o docker-compose.yml https://gist.githubusercontent.com/robzhu/a127a6bce1ea25b01d40efb57ad1c26e/raw/30a2927a901dd614a518319cfeaa63a6bd2648a4/gistfile1.txt nano docker-compose.yml #make your edits inside nano, then press CTRL+S, CTRL+X to save and quit
Your file should look like this:
version: "3" services: valheim: image: mbround18/valheim:latest ports: - 2456:2456/udp - 2457:2457/udp - 2458:2458/udp environment: - PORT=2456 - NAME="YOURSERVERNAME" - WORLD="Dedicated" - PASSWORD="ATLEAST5CHARACTERS" - TZ=America/Chicago - PUBLIC=1 - AUTO_UPDATE=1 - AUTO_UPDATE_SCHEDULE="0 1 * * *" - AUTO_BACKUP=1 - AUTO_BACKUP_SCHEDULE="*/15 * * * *" - AUTO_BACKUP_REMOVE_OLD=1 - AUTO_BACKUP_DAYS_TO_LIVE=3 - AUTO_BACKUP_ON_UPDATE=1 - AUTO_BACKUP_ON_SHUTDOWN=1 volumes: - ./valheim/saves:/home/steam/.config/unity3d/IronGate/Valheim - ./valheim/server:/home/steam/valheim - ./valheim/backups:/home/steam/backups
ATLEAST5CHARACTERS with a valid server name and password. Notice that this compose file also enables automatic updates and backups! It's time to bring up the server. Run:
sudo docker-compose up
After a few moments, you should see server output like so:
You can now close the Lightsail SSH browser window and your container will continue to run in the background.
Time to connect! Copy the IP address of your instance in the Lightsail console:
Launch Valheim and click "Join IP"
Paste the IP address into the IP address input. If you are running the server on a different port, also append the port number.
Click Connect and your adventure begins!
How to upload your current world to your new Valheim server:
If you've been playing Valheim alone or hosting a server from your PC, you probably want to move your world to the dedicated server.
- Connect to the instance and stop the Valheim server by running
sudo docker stop $(docker ps -aq)
- Open the worlds directory on your PC, for example:
C:\Users\%USERPROFILE%\AppData\LocalLow\IronGate\Valheim\worlds. There should be two files there:
YOURWORLD.fwl. You need to get these files onto your dedicated server. The best way to do this is with scp, but since we didn't set up an SSH key for Lightsail, you can upload your files a hosting service like Dropbox and download them from your server.
- Upload these files to a file hosting service, such as Dropbox. In your Dropbox folder, right-click and selected "Copy Dropbox link".
- In your Lightsail instance, download these two files to your
cd ./valheim/saves/worlds wget https://www.dropbox.com/s/<FILE_ID>/YOURWORLD.db?dl=0 -O YOURWORLD.db wget https://www.dropbox.com/s/<FILE_ID>/YOURWORLD.fwl?dl=0 -O YOURWORLD.fwl
docker-compose.yml and edit the
WORLD property (line 12) to match the name of your .db/.fwl files. For example, if your file is called
Valheim.db, then your
docker-compose.yml file line 12 would contain
5. Restart your server
sudo docker-compose up