Valheim
80 lượt đánh giá
Self Hosted Dedicated Server
Bởi Namischa và 1 cộng tác viên
This guide will allow you to create one or multiple dedicated servers for your Valheim game. This process also works for V Rising as well. Note that this guide is meant for players who have some basic networking knowledge, know how to access your router's admin panel to do port forwards, and know how to use the Windows firewall system. This guide was specifically created for Windows 10+ users. The Auto Server World Back-Up step can be used for other purposes by tweaking it to serve your specific non-Valheim related needs.

IMPORTANT: Some Internet Service Providers may disable port forwarding. You will need to contact your ISP to enable this feature. Note that Telus and Shaw in Canada do not disable port forwarding.

Please follow me on Youtube =^o^=
Please show me some love and support, by subscribing to my Youtube channel here: Click here for Thorny Lunacy's Gaming & Slice Of Life Vlogs

In This Guide
0. Overview
1. Create World
2. Install Valheim Dedicated Server Tool
3. Port Forward
4. Firewall Exceptions
5. Copy/Move World Files Over
6. Log-In Locally
7. Log In Remotely
8. Host Multiple Servers (optional)
9. Auto World Back-Up (optional)
10. Sub Domain Connection (optional)
11. Common Issues (FAQ)
3
4
   
Giải thưởng
Yêu thích
Đã yêu thích
Bỏ thích
1. Create World
1. Launch Valheim.

2. At the Start Game window, click the New button.

3. Enter a name and a seed.

4. Select the new world you created and enter it. Go through the intro sequence until you get to the spawn stones. It doesn't matter whether you use a new or old character.

5. Log out of the game.

6. Click the Start icon on the taskbar. Type: %appdata% and click into it.

7. From the appdata folder, go into LocalLow, then IronGate, then Valheim, then Worlds.

8. Find the two files that are named after the world name you created. The two files have the extensions: db and fwl. You will move/copy these to the server later.
2. Install Valheim Dedicated Server Tool
0. Install Steam onto the server computer, log in with your own account. You can log into more than one place at a time.

1. In Steam, filter out your list to show tools.

2. Find Valheim Dedicated Server Tool and install it.

3. Go to where you installed the server app, and make sure File Name Extensions are turned on.

4. Create a txt file and rename it to start-valheim-server.bat

5. Edit start-valheim-server.bat with Notepad.

6. Copy the following and paste it into the bat file.

@echo off set SteamAppId=892970 echo "Starting server PRESS CTRL-C to exit" valheim_server -nographics -batchmode -name "YourServerName" -port 2457 -world "TheWorldFileName" -password "YourOwnPassword"

7. Save that file.

8. The port number may vary. 2457 worked for me, but 2456 might work for you instead. Depends on your router/modem.
3. Port Forward
0. Open up your command prompt from Start by typing CMD.

1. Type: ipconfig

2. Note down your IPv4 address. Ours is: 192.168.1.68 - yours may be different. Close CMD.

3. Go to your router's admin panel from your internet browser. With Telus, we use http://192.168.1.254 - yours may be different.

4. Log into it, and go to Firewall then go to Port Forwarding. This may differ with you ^_^. Just find Port Forwarding.

5. In LAN IP Address, type in your IPv4 address.

6. In WAN/LAN Start Port: 2456

7. In WAN/LAN End Port: 2458

8. Protocol: TCP.

9. Repeat 5 to 8 to add an entry for UDP if the above doesn't let you select both TCP and UDP at the same time.
4. Firewall Exceptions
1. Click Start, type: Firewall. Choose Windows Defender Firewall With Advanced Security.

2. Click into Inbound Rules.

3. Click New Rule on the right side.

4. Under General tab, add Valheim TCP in Name, make sure the check box for Enabled is checked and action is Allow the Connection.

5. Under Protocols and Ports, the type is TCP. Local Port is Specific Ports, in the box, enter 2456-2458, Remote Port is All Ports. Click Apply and Okay.

6. Repeat step 5 to add Valheim UDP with the type as UDP.

7. Add another New Rule and this time in General tab name, enter Valheim TCP Server.

8. Under Programs and Services, select the path and Dedicated Server executable (valheim_server.exe) for "This Program".

9. Under Protocols and Ports, make the type TCP and everything else is All Ports.

10. Repeat step 7 to 9 but for Valheim UDP Server for the name and UDP for the type.
5. Copy/Move World Files Over
In "Create World Step 8", copy or move those files to the same location in the server. So on the server computer, at start, type %appdata% and go to the appropriate Valheim world folder and drop them in there.
6. Log-In Locally
1. Start Valheim game.

2. In the Start Game window, click "Join Game" tab.

3. Click Join IP.

4. Enter your server's IPv4 address followed by the port. Eg: 192.168.1.1:2457 - if 2457 doesn't work, try 2456 or 2458.

5. Enter password when prompted and have fun.
7. Log In Remotely
1. Go to your internet browser. Type My IP.

2. Note down this IP address.

3. Give it to your friend and ask them to enter it into the Join IP box along with the port.
8. Host Multiple Servers
You can host more than one Valheim world at the same time, by creating extra worlds, place them in the same world folder on the server, and port forward another set of numbers. Make sure their names are all different. On our server, we host 3 Valheim worlds using ports 2456-2458, 3456-3458, and 4456-4458. To start each server, make sure to create a different BAT file for each located inside the Valheim Dedicated Server folder. Eg: server-start-1.bat, server-start-2.bat, etc. You can run them all simultaneously, just be aware that you need better hardware, the more games you host.
9. Auto World Back-Up (optional)
This batch file will run once a day at the selected time. In the designated back-up folder, you will find a folder with the date in which the back-up happened and the time. Note that it will back-up everything inside the Valheim world folder. This script will also work for the client-side as well.

A big thank you to CrucialH for fixing and improving the CMD BAT script.

0. Find a suitable location to store all of your server world back-ups and create a folder for it. Eg: the root of C drive or some other drive. Mine is on D drive called Valheim-Server-Back-Ups.

1. Go to where you installed the Valheim Dedicated Server tool.

2. Create a txt file and rename it server-world-backup.bat - this is on the notion you already enabled file extension view.

3. Right click the bat file and edit it with notepad.

4. Copy and paste the following into the bat file:

echo Thorny_Lunacy_IG Loves Back-ups with CrucialH's help! SET "sourcePath=%appData%\..\LocalLow\IronGate\Valheim\worlds" SET "targetRootPath=D:\Valheim-Server-Backups" for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a SET "timevar=%TIME:~0,2%-%TIME:~3,2%" SET targetDirectoryName=%date%_%timevar% echo trying to copy %sourcePath% to %targetRootPath%\%targetDirectoryName% REM pause robocopy "%sourcePath%" "%targetRootPath%\%targetDirectoryName%" /E /MIR REM pause

Where it says SET "targetRootPath=D:\Valheim-Server-Backups", you have to change the D:\Valheim-Server-Backups" drive letter and folder name accordingly. Perhaps you want your world saves to be backed up on C drive or E drive?

5. Save and exit the file.

6. Click on Windows Start, and type: task scheduler

7. Open the program.

8. On the right menu, click "Create Basic Task".

9. In the name field, type: Valheim Server World Back-Ups

10. Click Next, and choose: Daily

11. Click Next, and select the preferred start day and time. Leave the time zone check box unchecked.

12. In the Recur Every field, type in how often you want the back-up to happen. Daily = 1, Every two days = 2, etc. Click Next after.

13. Choose Start A Program, then click Next.

14. Under Program/Script, click the Browse button. Find and select the server-world-backup.bat file. Afterwards, click the Finish button.

-----

NOTE: If you don't want to use Windows Task Scheduler to automatically back-up your server files, and instead manually run the BAT file, skip steps 6 to 14. Right click the BAT file and click Send To Desktop. Whenever you want to, you can double click the BAT shortcut on your desktop to run the back-up process.

POWERSHELL SCRIPT VERSION: Please scroll down to the comments and look for CrucialH's comment for the Powershell version.

10. Sub Domain Connection (optional)
This is particularly useful if your internet service isn't using a static IP address which means your external IP changes every now and then. This is also useful, if you prefer to use a sub domain name to login locally, if you have problems remembering strings of numbers. The steps below are for cPanel users, but the premise is still similar for non-cPanel users.

Further note, that while the instructions below reflect Sub Domain configurations, ultimately, you can also do it for the domain itself. However, it's not a great idea especially if you use your domain name for a website.

1. Log into your domain registrar or hosting service.

2. Go into your Zone Editor and click the Manage button for the specific domain.

3. Click the "Add A Record" or "Add Record" function.

4. In the Valid Zone Name field, enter: YourSubName.YourDomainName.com. <-- make sure the full sub domain address ends with a dot. Replace "YourSubName" with something like gaming or valheim or whatever you want. Replace "YourDomainName.com" with your own domain name. So basically the result in my case would be "gaming.thornylunacy.com". Make sure to make them all lowercase.

5. TLS at 1200 is fine.

6. Make sure the record type is an A Record.

7. In the IPv4 Address field, enter either your external IP for your players who log in remotely, or your internal IP if you are logging in locally. Locally as in your server is located in the same place your gaming PC is at. For example, my players who log in remotely would use "gaming.thornylunacy.com", but for people logging in locally from within my home, they would use "localgaming.thornylunacy.com".

8. Save the record.

9. When your players want to connect to the game directly remotely, they would enter: YourSubName.YourDomainName.com:Port# - for example: gaming.thornylunacy.com:2457 - to log in locally, it would be: localgaming.thornylunacy.com:2457

10. As an extra note, it's fine to use one sub-domain for multiple games you host. For example, if you run a Minecraft server on top of a Valheim server, your players can simply create a direct connection using the same sub domain address with the Minecraft server's port #. Eg: gaming.thornylunacy.com:25565

For the tech savvy network admins: I tried creating a SRV record for the port #, but it didn't work for some reason. Hence why players still need to attach a port # to the sub-domain address.
11. Common Issues (FAQ)
Updated: 2022-June-02

i. My power went out. I turned my server back on, but no one can connect to it again.

a. From your server computer, open up Powershell or CMD and type: ipconfig

b. Check your IPV4 hasn't changed. If it has, you have to update your port forwarding IP to reflect this change.

c. Open up your browser from the server PC, and search: my ip

d. If the IP has changed, note this down and give it to your friends who connect remotely. Also, you will need this new IP address for your sub-domain if you assigned your IP address to a sub-domain name.

ii. What mod manager would you recommend for the server?

R2ModManager. It makes things a lot easier for your players to update as a package. One of GinsengSamurai's Steam friends (Bjorn) has this setup on their server and it's super convenient to keep everyone on the same page. However, GinsengSamurai himself doesn't use any mods on his servers, not wanting to risk world save corruptions. Until Valheim is out of Early Access, using mods will always be a risk. So make sure to back-up your world saves periodically.
15 bình luận
twitchie1 17 Thg05, 2023 @ 9:45pm 
I have a question i recently set up a dedicated valheim server but my ping in game is around 60-80 makes no sense being the computer is on my same internet and network 1 gig fiber, is there settings i need to change to get it pinging better?
Jebbalon 1 Thg05, 2023 @ 9:21pm 
A few items..

1 - The link to your youtube doesn't work

2 - There have been changes to where character/world saves are located. If you have cloud saves enabled the saves go into the steam user data folders (not appdata) I think saving to the appdata folders is still valid but not sure. Maybe that the server looks in appdata but if you have a world saved with cloud it will not be in there. ?

3 - FYI for those that don't know, the Valheim Dedicated Server download does include a pdf doc with some of this info...

4 - In the documentation pdf that comes with Valheim Dedicated Server download it mentions there are default settings that will save the world periodically. Includes 4 backups and you can change that number along with the timing of the saves (2 hours, 12 hours, etc)

I'm still trying to get a Virtual machine setup to run the valheim server and this guide is helping with all that. :)

Thanks
- Jebbalon
Darth Futuza 17 Thg04, 2023 @ 10:19pm 
Is there a guide for doing it on linux/do they make linux builds?
Shrapnel 15 Thg04, 2023 @ 4:32pm 
Thanks for making this guide!
Tint 14 Thg04, 2023 @ 10:42pm 
Ahh ok I get it now after researching a bit more. Kinda like if I wanted a server up 24/7 so friends can hop on whenever and I don't have to be on.
Namischa  [tác giả] 14 Thg04, 2023 @ 12:53pm 
No no of course not. This is just a comprehensive guide to getting it all properly sorted. Otherwise, it's just a matter of starting a new game and opening it up a multiplayer game in the in-game menu.
Tint 9 Thg04, 2023 @ 12:36pm 
Geez you have to do all this just to play with friends?
Namischa  [tác giả] 30 Thg05, 2022 @ 2:45am 
@CrucialH, thank you for all of that. I replaced the much better version of the BAT script in the guide with your version of the BAT script. I wish there was a way to pin your comment for the Powershell script. I added a credit to your name in that section. ^_^ Also added a note at the end of that section for those who want to use the PS1 version you created.
CrucialH 30 Thg05, 2022 @ 1:32am 
Yay - no edit-function here - small error within the PS-script - the optional-part should of course be this (hardcoded path .. *yikes*):

[code]
Get-ChildItem -Path "$targetRootPath" |
Where{$_.Attributes -like '*Directory*'}|
Sort-Object -Property {$_.Name} -Descending |
Select -Skip 14 |
Remove-Item -Force -Recurse [/code]
CrucialH 30 Thg05, 2022 @ 1:24am 
The last part of the script is completely optional and can be removed if it feels to dangerous

Sadly the task scheduler can't handle PS-files by default, so you need another script to run the powershell-script.
E.g. execValbak.bat (there are other ways to do this, but this seems to be the easiest)
[code]
powershell.exe -ExecutionPolicy Bypass -File "D:\Temp\valheim Backup\valbak.ps1" [/code]

If this doesn't work, you might need the full path of the powershell.exe
The "ExecutionPolicy" is needed to allow the script's execution, by default Microsoft considers this as a possible thread. (Thanks for not letting me execute my own scripts...)

Now use the .bat file in your task scheduler and you're done
... of course modify the target-directories first

Feel free to use any of this stuff .. or not :)
(Whoops, this got a "little" longer than expected - so I had to split it up)