Valheim Windows dedicated server setup guide v1.4 by @Frosty on Valheim Discord. (Accurate as of 11 Feb 2021, Version 0.143.5)
This guide is intended for people who want to play Valheim with their friends online, and who want a persistent server rather than relying on one client to host. This use case assumes you'll host and play on the same PC on a LAN behind a typical router and friends will join from the internet.
There's 6 basic steps to this guide, plus an additional step for patching the server, and then a detailed FAQ at the end:
STEP 1 - Installing and configuring the server
STEP 2 - Adding port forwarding rules to your router, this allows friends on the internet to connect through the router to your server
STEP 3 - Opening ports on the servers firewall, to allow the traffic direct access to the Valheim server application.
STEP 4 - Local testing
STEP 5 - Friends connecting
STEP 6 - Troubleshooting remote connections
STEP 7 - Upgrading the dedicated server after a patch
FAQ - Other server admin and network related questions
STEP 1 - Installing the server
Open your steam client, select the "Library" Tab, make sure the filter at the top left is set to "GAMES AND TOOLS", then use the search bar to search for Valheim. You should see "Valheim Dedicated Server" as one of the tools, right click it and select "Install".
Once installed, right click Valheim dedicated Server in your steam list, select the "Manage" menu, and under that select "Browse local files", this will open up the installation directory.
Inside the installation directory there's already a template batch file for starting the server which you can configure. Right click the file "start_headless_server.bat" and select "edit" to open it in notepad.
The 7th line sets the properties of the server, set you preferred values for:
Name - This is the name that appears in the server browser, make this descriptive.
World - This is the name of the world used, make this unique you dont want it to match anyones local world names
Password - Set a strong password, this is required and must be 5 characters or longer, you also can't make this the same as the server name or the world name, otherwise the server won't start.
Save the file. You may also want to take an additional step of making a backup copy of this file just in case. if you have to update/patch or repair server files for any reason and you overwrite the bat file, you'll lose your settings. Simply make a copy of the file outside of the server installation directory.
STEP 2 - Port forwarding your router
First you need to know the IP address of your router to connect to it, to find open the start menu, search for "CMD" and run it, you should have a black command prompt windows, type:
And hit enter. You should have a list of network adapters, you need to make a note of 2 values, the "IPv4 Address" and the "Default gateway". The default gateway is your routers address, enter this IP address into the address bar of a browser window and you'll be taken to the login page for your router. You might need a username and password, typically these come on stickers printed on the router. If you don't know it and can't get it, contact your ISPs tech support.
There's thousands of different types of router each with a different user interface, so precise instructions for the next part is impossible. You're looking for port forwarding options, these might be listed under submenus like "advanced", "firewall" or "security". Just work your way through the different menus until you find an option that allows you to add port forwarding rules.
The goal is to forward 3 ports, the default port of 2456 and the next 2 (2457 and 2458) so they forward to your servers IP address. If your router allows port forwarding of a range of ports then use that, otherwise you'll need to create 3 rules, one for each port number.
The key values you'll need are:
internal/local start port 2456
internal/local end port 2458
internal/local IP address (this is the IPv4 address you got from the ipconfig results)
External/remote start port 2456
External/remote end port 2458
Protocol TCP & UDP (you want both)
Sometimes routers accept a range of ports but only have 1 text box to put the value in. In this case, use a hyphen to indicate a range, for example 2456-2458. If your router doesn't allow rules with ranges at all, then create 3 separate rules, one for each individual port 2456,2457, and 2458.
Lastly, if you struggle with this section, make sure to check out https://portforward.com/ this website has guides for how to port forward on many of the more common routers with much more specific instructions.
STEP 3 - Opening firewall ports
Windows as standard comes with windows firewall enabled, which blocks all incoming traffic unless you create rules to allow it. However some security software like anti-virus protection can disable windows firewall and install their own custom one. If you have a custom firewall you'll have to translate these instructions yourself.
Open start menu and type in "firewall", select Windows Defender Firewall and then click on the "advanced settings". At the top left of the window you should see "Inbound Rules", select that, and on the right side click "New Rule..."
In the new Rule Wizard, select the type of rule as "Port", click next. Select "TCP" and select "Specific local ports", type in the text box 2456-2458 and click next. Select "Allow the connection", click next. Make sure Domain, Private and Public are all ticked, click next. Give it a memorable name like "Valheim server TCP". click Finish. You need to repeat the above steps again with the same details, except rather than TCP, select UDP. You should now have 2 rules for both TCP and UDP traffic.
Lastly, order the windows firewall rules by name, search through the list looking for rules with the exact name "valheim_server", windows might automatically create rules for the server executable valheim_server.exe that conflict with the rules you have, right click any of these rules and select "delete".
STEP 4 - Local Testing
First we want to test locally to make sure the server is running and configured correctly, this means if you have problems with friends connecting from the internet you can rule out server config as a problem and makes troubleshooting later on much simpler.
Start the server by double clicking the "start_headless_server.bat" file, this should open a black CMD window, it will take a few seconds to initialize and should eventually read out a line with "Game server connected" which indicates it's finished loading. If you've not got this far then you've probably made a mistake in STEP 1, common mistake is a password missing or too short (at least 5 chars).
If the server starts OK, then connect yourself to verify it's working properly. Open Steam, click the "View" menu at the top, and select "Servers", switch to the "Favorite" tab, right click and select "Add server by IP address" and in the text box type:
127.0.0.1 is a special IP address that points to your own computer, and the listening port for connections is 2457 (1 port above the default)
Double click the server, enter the password you set in STEP 1. It should launch the game and take you directly to the character selection screen, once you select or create a character, click OK it will connect you to the server. If you get a "server is not responding error" you might find that server listing is buggy, this is also a known problem. If you press F5 in the server list to refresh it, and then immediately double click to join, you should connect.
Do not give 127.0.0.1 to your friends to connect to from the internet as it won't work, make sure to give them your external/WAN IP address detailed in the next step.
If you still cannot connect at this stage because you're not connecting through the router or firewall you can rule out STEP 2 and 3. This means something is wrong with the server install/config, double check the batch file looks correct, that your password meets the length requirements, that the server is starting correctly when you run it. One other problem at this stage where you cannot even connect locally might because you closed down the server incorrectly (clicking the X on the CMD window) which causes the window to close but the server process to run in the background still. In this case close down the server, CTRL + ALT + DEL and look through the process list for valheim_server and end any processes with this name. Then start the server again. If this was your problem, in future shut down the servers by opening the CMD window for the server and press CONTRL+C. It's important you do this because this way initiates a final save of your game state.
STEP 5 - Friends connecting
If steps 1-4 all worked now your friends need to connect. There are known bugs with the server listing, both in game with the custom server browser and with the steam server list for Valheim games. if your server name is not appearing for friends then they can connect to your server the same way you did during testing, except they will need to use your external/WAN IP address.
To find this, browse to https://www.whatismyip.com/ and it will tell you your external IP at the top under "My Public IPv4 is:"
Add the port to the end of this address after a colon character. The connecting port is +1 to the port specified in the server config so by default is 2457 (2456+1). So for example if your IPv4 address was listed as 111.222.333.444 then you'd give them 111.222.333.444:2457 to connect to.
Connect by opening Steam, click the "View" menu at the top, and select "Servers", switch to the "Favorite" tab, right click and select "Add server by IP address" and type in address. Make sure after it has been added to refresh the saver favourites with the f5 key. Connection attempts seem more reliable if done rapidly after a refresh of the server status, I have no idea why.
If they still have problems connecting then you may have made a mistake in steps 2&3. Go back and double check all of the values are exactly what they should be, and if everything looks correct, move on to STEP 6 for troubleshooting common mistakes and problems.
STEP 6 - Remote testing & troubleshooting
Right now servers aren't being reliably listed in the server browser, it's a known issue affecting most people. If your server does not appear it may not necessarily be because you've made a mistake. Your friends should first try connecting directly as explained in STEP 5. If your friends cannot connect directly then there's a mistake somewhere in STEP 2 & 3, in the port forwarding or firewall rules.
To rule out the firewall rules as a source of the problem you can disable your firewall completely. Only do this temporarily as a diagnostic to check if your firewall rules are the problem, but NEVER leave your firewall disabled permanently. If disabling the firewall fixes the problem then you know the firewall rules are wrong, if it doesn't then you know the port forwarding rules are wrong.
If the firewall rules appear to be the problem, then re-enable the firewall and double check the rules you created are correct. If you're unsure then delete the rules and re-create them as described in STEP 3. Also double check to make sure windows hasn't automatically created conflicting firewall rules, it can create rules with the name of the server executable (valheim_server) and if these appear in your firewall rules list, delete them. The only valheim rules for the server you need are the ones you create yourself in STEP 3
If disabling the firewall doesn't help then the port forwarding rules will be the problem. Double check the rules look correct, if they do look accurate then try rebooting the router, this has solved connection problems for some people.
If you have a server that was previously working and it has suddenly stopped and friends can no longer connect to you, but you can connect yourself locally, then it's possible your IP has changed. Some ISPs have dynamic IP addresses which automatically change from time to time, in which case visit https://www.whatismyip.com/ to check the WAN IP is the same, if it has changed give the new WAN IP and give that to your friends (remember to add the game port +1 to the end). A lot of ISPs can upgrade you to a static IP address if you call their support but might charge a small fee, this would prevent this problem from happening in future.
Another possibility is the LAN IP address of your server has changed, in this case follow STEP 2 again, after using CMD to run ipconfig if the local/LAN IP has changed then simply log into your router and update your existing port forwarding rules to point to the new IP address of your server. You can also prevent this from happening again in future but it's beyond the scope of this guide. If you're interested in doing this search Google for guides on how to specify DHCP IP address ranges on your router, and how to set a static IP address on your server.
Lastly if you still cannot connect to your server from the internet after all this troubleshooting, it's plausible that your ISP uses a technology called CGNAT or does port blocking. If nothing else in this guide works, try contacting your ISPs tech support and ask if this is the case, if they do either of these things hosting will be impossible.
STEP 7 - Game patching
If you've just setup your server for the first time you can skip this step for now as it will be the newest version already. The game is being patched frequently as it is in early access and under constant development. As such you'll need to patch the server to keep up with the client updates.
First make sure that you've either taken a backup of your start_headless_server.bat OR you've at least made a note of the exact values for -name, -world, -port, and -password. The batch file will be overwritten during the update and you'll need to replace these values after the update. If the world name doesn't match after the update then you'll end up with a different/fresh game world.
Stop the server CMD window from running, make sure to do this "safely" by selecting the CMD window for the server and pressing CTRL+C, this shut down method closes the sever properly and causes it to save the current state of the world on exit. Once shut down open steam, switch the "Library" tab, make sure "GAMES AND TOOLS" is selected as the filter top left. Then search for "Valheim Dedicated Server", right click it and select "Properties". In the properties window switch to the "LOCAL FILES" menu, and click the button "Verify integrity of game files...". This will re-acquire any updated game files and replace them automatically.
Once this is done, edit the start_headless_server.bat file by right clicking it and selecting "edit", and on the line that starts with valheim_server make sure to replace the parameters with the old ones from your backup, the -name -port -world and -password
Start your server again and you're good to go.
Note: the -public parameter has been depreciated now, this can be removed from the list of parameters
Other server related FAQ
Q - What ports are needed for a dedicated server?
A - Whatever port you've configured the server to use (default is 2456) and the next 2 ports above it (default 2457 and 2458)
Q - What port should people connect to?
A - The port +1 from the port configured in the server, default port is 2456 so you'd connect to 2457
Q - Can I remove the password?
A - No, despite what the documentation says, the current version of Valheim must have a password and it must be at least 5 chars long
Q - How often does the server save the state of the world?
A - Every 30m or when the server is closed down properly (pressing any key in the console window)
Q - Can I change the backup interval?
A - No, not yet
Q - How can I add admins?
A - Edit this text file C:\Users\<USERNAME>\AppData\LocalLow\IronGate\Valheim\adminlist.txt where <USERNAME> is your windows username. Add the Steam64 IDs for the steam users you wish to make admins, 1 ID per line. The steam64 ID is the 17 digit long number.
Q - How do I get my steam 64 id
A - Open Steam, click the "steam" menu at the top left, click "settings", and under the Account menu click the "View Account Details" link at the top right. It should list your steam ID at the top. If this is not 17 digits long, then you can use https://steamid.io/ to convert/lookup your ID.
Q - How do I access server commands
A - Connect with a client whose Steam ID is in your adminlist.txt and press F5 in game to access the console
Q - Is there a list of commands I can use?
A - Yes, the following commands work on a dedicated server
Q - Can I use the cheat commands on a dedicated server as admin?
A - No, these are disabled for dedicated servers
Q - Can I connect directly to an IP in game?
A - No, use the steam server browser and add specific IP:port into your favorites. This is found in the steam client by clicking "View and then selecting "servers"
Q - I can only see a subset of all the servers listed publicly and/or my server isn't listed, is this normal?
A - Yes, the server list both in game and in steams master list are both buggy. it's recommended you use steams server list and add specific server IPs to your favourites tab.
Q - What is the recommended maximum ping for players?
A - Experience so far shows that the game struggles with pings above about 100ms and you may encounter problems
Q - Does the game pause when there's no players connected?
A - Yes, the game logic pauses when no one is connected, to reduce demand on the CPU.
Q - Where are the game worlds saved?
A - C:\Users\<USERNAME>\AppData\LocalLow\IronGate\Valheim\worlds where <USERNAME> is your windows username. The files are named after the world name and you need both the .db and .fwl
Q - Can I move existing worlds from singleplayer to a dedicated server?
A - Yes, there's an easy guide here https://quoramarketing.com/valheim-how-to-transfer-save-from-pc-to-dedicated-server/
Q - Can I increase the server player limit?
A - No
Q - How can I get my external/WAN IP address?
A - Browse to https://www.whatismyip.com/ and copy the IPv4 address. The connection port is +1 to the port configured in the server, by default 2457
Q - How do I connect to my own server?
A - If you host the server and use the game client on the same PC then you can connect using the local loopback address 127.0.0.1:PORT. The connection port is +1 to the port configured in the server, by default 2457
Q - Can I connect or test connection to my own server with my external/WAN IP?
A - No, if you're testing from the server, or any other computer on the LAN you need to use the LAN IP address
Q - How do I find my local/LAN IP address, and/or my gateway/router IP address?
A - Hold windows key + R to open the run menu, type "cmd" and hit enter to open a command prompt. In there type "ipconfig" without quotes, and look for "IPv4" for your local address, and "Default gateway" for your router.
Q - How do I get my routers username/password
A - It's normally printed on the physical router on the back or bottom. If not you should contact your ISP tech support.
Q - What happens if I get the error version mismatch when trying to connect
A - There has been an update to the client and the server needs the same update, check out STEP 7 in this guide on how to do that.
Q - My world loads but none of the buildings or objects do, how do I fix this.
A - This is probably due to the filename of your world having its name changed. The name you chose for your world is referenced both as the file name but also inside the file itself, so it's not safe to simply rename your world files and use the renamed version on the server. To fix this rename your world file back to its original name. (this might be case sensitive, unconfirmed)
Take care and stay safe.