RE:NODE

Install a Valheim dedicated server on Windows

By RE:NODE Team
11 min read


On Windows there are two ways to get the Valheim dedicated server: install "Valheim Dedicated Server" from the Tools section of your Steam library, or download app 896660 with SteamCMD into a folder of your choosing. Either way you then copy start_headless_server.bat, set the server name, world and password in your copy, allow valheim_server.exe through Windows Defender Firewall on UDP 2456-2458, and start it. For anything longer than an evening, run it as a Windows service with NSSM, configured to send Ctrl+C on stop so the world saves. The traps are specific to Windows: closing the console window with the X kills the server without saving, the firewall prompt is easy to answer wrongly, and a service running as the SYSTEM account saves its worlds somewhere nobody thinks to look.

The launch arguments themselves are covered one by one in the Valheim launch arguments reference; this post is the Windows install and the service around it.

Steam Tools or SteamCMD: which to use#

Both deliver identical server files. The difference is in who updates them and where they live.

Steam Tools copySteamCMD
Needs the Steam clientYes, logged inNo
Install locationsteamapps\common\Valheim dedicated serverAny folder you choose
UpdatesSteam, automatically, when the client runsWhen you run the update command
Good forA server on your gaming PC for one eveningA machine that runs the server permanently

The Steam Tools copy is the quick route. In the Steam library, switch the filter to include Tools, find "Valheim Dedicated Server" and install it. It lands in C:\Program Files (x86)\Steam\steamapps\common\Valheim dedicated server on a default install. The catch is that Steam updates it whenever it likes, which is convenient for a vanilla server and a problem for a modded one, and that it ties the server to a desktop session with Steam running.

SteamCMD is the route for a box that does nothing else. Download steamcmd.zip from Valve's developer site, unpack it into a folder such as C:\steamcmd, and run:

code
C:\steamcmd\steamcmd.exe +force_install_dir C:\valheim\server +login anonymous +app_update 896660 validate +quit

The first run updates SteamCMD itself, then downloads the server. You do not need to own Valheim; the server app downloads anonymously. +force_install_dir must come before +login, and the path should be one your user can write to - avoid Program Files, where every write needs elevation and silently goes to a virtualised folder if it does not get it. SteamCMD explained covers the command's anatomy and its error codes.

The same command updates the server later. Stop the server first; SteamCMD cannot replace files a running process holds open, and you will get a half-updated install.

What is in the server folder#

After either install, the folder holds:

  • valheim_server.exe - the server itself.
  • valheim_server_Data - Unity's data folder. Never edit anything in here.
  • start_headless_server.bat - the sample start script.
  • steam_appid.txt, steamclient64.dll and related Steam API files the server needs to register.
  • Documentation such as a short PDF guide from Iron Gate, depending on the build.

Worlds are not in this folder. By default the server saves under the profile of the user that runs it, at %USERPROFILE%\AppData\LocalLow\IronGate\Valheim, with worlds in worlds_local and adminlist.txt, bannedlist.txt and permittedlist.txt beside that folder. That fact drives the service section below. Valheim file locations lists every path on Windows and Linux.

Editing start_headless_server.bat safely#

The shipped script looks like this, give or take the comments and whether -crossplay is already in the sample line, which depends on the build:

start_headless_server.bat (as shipped)
@echo offset SteamAppId=892970echo "Starting server PRESS CTRL-C to exit"REM Tip: Make a local copy of this script to avoid it being overwritten by steam.REM NOTE: Minimum password length is 5 characters & Password cant be in the server name.REM NOTE: You need to make sure the ports 2456-2458 is being forwarded to your servervalheim_server -nographics -batchmode -name "My server" -port 2456 -world "Dedicated" -password "secret"

Follow the tip. Every update - Steam's automatic one or validate - restores this file, and your server name and password with it. Copy it to start_valheim.bat in the same folder and edit the copy:

start_valheim.bat
@echo offcd /d "%~dp0"set SteamAppId=892970valheim_server.exe -nographics -batchmode -name "Longship Crew" -port 2456 ^  -world "Midgard" -password "herring-barrel-42" -public 1 ^  -saveinterval 900 -backups 4

What each change does:

  • cd /d "%~dp0" switches to the folder the script lives in, so it works from a shortcut, a scheduled task or a service. Without it, double-clicking from Explorer works but launching from anywhere else may not find valheim_server.exe or its data.
  • set SteamAppId=892970 stays. It is the game client's app id, and the server uses it to identify itself to Steam. Do not change it to the server's id.
  • The ^ at the end of a line continues it in a batch file, which keeps a long command readable. There must be nothing after the caret, not even a space.
  • -saveinterval 900 saves every 15 minutes instead of 30, halving what a crash can lose.

Add -crossplay only if Xbox or Game Pass players need to join; the trade-offs are in Valheim crossplay and Xbox players.

First start and the clean stop#

Double-click your copy. A console window opens and scrolls the log. On the first start a new world is generated and saved, which takes noticeably longer than later starts. Look for Load world: with your world name and Game server connected, which means Steam accepted the registration. With -crossplay, a line with the six-digit join code follows.

To stop the server, click into the window and press Ctrl+C, then wait. The server saves the world and exits; on some builds the window then asks Terminate batch job (Y/N)?, which is Windows asking about the script, not the server - the save has already happened, and either answer is fine.

Do not close the window with the X. That ends the process without the shutdown sequence, and everything since the last save is gone - up to thirty minutes at the default interval. Logging off Windows, a forced reboot for updates, or ending the task in Task Manager have the same effect. This is the strongest argument for a service, which can be told to send Ctrl+C.

If the world you expected does not load and a new one is generated instead, the -world name does not match the file name in worlds_local. Your old world is untouched; correct the name and restart. Start-up failures by log message are collected in Valheim server crashes on start.

Windows Defender Firewall and port forwarding#

The first time valheim_server.exe opens a network port, Windows Defender Firewall shows a prompt asking which networks to allow it on. Two ways this goes wrong:

  1. The prompt appears behind the console window, nobody answers it, and inbound traffic is blocked.
  2. Only "Private networks" is ticked while Windows considers your connection Public - common on a freshly installed machine or a server in a data centre - and the rule never applies.

Rather than trust the prompt, create explicit rules from an elevated PowerShell:

code
New-NetFirewallRule -DisplayName "Valheim UDP" -Direction Inbound `  -Protocol UDP -LocalPort 2456-2458 -Action Allow -Profile Any

UDP 2456 carries game traffic and 2457 answers Steam queries; the third port in the range is what the sample script's comment mentions and opening it costs nothing. The protocol matters: a TCP rule does nothing for Valheim. If you answered the prompt with "Cancel" earlier, Windows created a block rule for valheim_server.exe, and block rules win over allow rules. Find it under Windows Defender Firewall with Advanced Security, Inbound Rules, and delete it.

At home, forward the same UDP range on your router to the PC's LAN address, and give that PC a fixed address (a DHCP reservation) so the forward does not break when it gets a new one. On a cloud Windows server, the provider's network firewall needs the same rule as well. Valheim ports explained covers changing -port, running two servers on one machine, and testing whether a port is actually open.

Test by joining by IP from a machine outside your network: Join Game, Add Server, your.public.ip:2456. If that works and the community list still does not show the server, wait - the list can take several minutes - and see Valheim server not showing in the list.

Running the server as a service with NSSM#

A server in a console window stops when someone logs off, closes it, or Windows Update reboots the machine. NSSM, the Non-Sucking Service Manager, wraps any program as a Windows service: it starts at boot with nobody logged in, restarts after a crash, and - the part that matters for Valheim - can stop the program with Ctrl+C instead of killing it.

Download NSSM, put nssm.exe somewhere on the PATH, and from an elevated Command Prompt:

code
nssm install Valheim C:\valheim\server\valheim_server.exenssm set Valheim AppDirectory C:\valheim\servernssm set Valheim AppParameters -nographics -batchmode -name "Longship Crew" -port 2456 -world "Midgard" -password "herring-barrel-42" -public 1 -saveinterval 900 -savedir C:\valheim\savenssm set Valheim AppEnvironmentExtra SteamAppId=892970nssm set Valheim AppStopMethodConsole 60000nssm set Valheim AppStdout C:\valheim\logs\valheim.lognssm set Valheim AppStderr C:\valheim\logs\valheim.lognssm set Valheim AppRotateFiles 1nssm set Valheim Start SERVICE_AUTO_STARTnssm start Valheim

The service runs valheim_server.exe directly rather than the batch file, so NSSM's stop signal goes straight to the server. Line by line, the ones that are not obvious:

  • AppEnvironmentExtra SteamAppId=892970 replaces the set line from the batch file. Without it the server fails to register with Steam.
  • AppStopMethodConsole 60000 tells NSSM to send Ctrl+C on stop and wait up to 60 seconds for the process to exit before moving to harsher methods. A large world needs that time to write. Make sure the "Console" stop method is not disabled in AppStopMethodSkip; it is enabled by default.
  • AppStdout and AppStderr capture the log, since a service has no window. Create the logs folder first. AppRotateFiles 1 rotates the file when the service starts, so it does not grow forever.
  • -savedir C:\valheim\save is the line that saves you a lost afternoon. Read the next paragraph.

By default a service runs as LocalSystem. LocalSystem's profile is C:\Windows\System32\config\systemprofile, so without -savedir the server saves to C:\Windows\System32\config\systemprofile\AppData\LocalLow\IronGate\Valheim - and generates a fresh world there, because your existing world is in your own profile. Either pass -savedir to a plain folder, as above, and move your worlds_local folder and list files into it, or run the service as a normal user account with nssm set Valheim ObjectName .\valheim "password". A dedicated low-privilege local user plus -savedir is the tidiest combination.

Manage it like any service: nssm restart Valheim, sc query Valheim, or the Services console. nssm edit Valheim opens a GUI with every setting if you prefer to click. To update, stop the service, run the SteamCMD command, start it again.

Updates, restarts and backups on Windows#

Task Scheduler can run a small script nightly or weekly that stops the service, runs the SteamCMD update and starts the service again:

C:\valheim\update.bat
nssm stop ValheimC:\steamcmd\steamcmd.exe +force_install_dir C:\valheim\server +login anonymous +app_update 896660 +quitnssm start Valheim

Do not schedule that for a modded server. A Valheim patch breaks BepInEx mods until their authors catch up, and an automatic update brings the breakage to you at 4am. Updating a Valheim server covers when to update and what the Incompatible version error means.

The server's own -backups copies sit in the same worlds_local folder as the world, on the same drive. For real backups, copy the save directory elsewhere - another drive, a NAS, object storage - on a schedule, ideally right after the scheduled restart when the world has just been saved cleanly. Valheim server backups and world corruption has the strategy and the restore procedure.

Windows itself is the last trap. Windows Update reboots when it wants to unless you set active hours or a maintenance window. With NSSM and the Ctrl+C stop method a reboot is a clean stop, but the server is still down until it comes back. Running a game server on your everyday gaming PC also means the server competes with your game for the same CPU; Linux vs Windows game servers and self-hosting at home vs renting cover when it is worth moving off.

On RE:NODE the service, firewall and update questions do not arise: the server runs in its own container, both UDP ports come with the plan, Restart sends a clean stop so the world saves, and the launch arguments are fields on the Startup tab rather than a batch file you have to keep a copy of.

FAQ#

Can I play on the same PC that runs the server?

Yes. Start the server, then the game, and join by 127.0.0.1:2456 or your LAN address. The server and the game compete for CPU, so a mid-range PC handles a few friends better than ten. Everyone else joins by your public address.

Why did my world disappear after I set up the service?

Almost certainly the service runs as a different account from the one you tested with, so it saves in that account's profile and generated a new world there. Your old world is still in your own AppData\LocalLow\IronGate\Valheim\worlds_local. Point -savedir at a fixed folder and move it there.

Does the Steam client need to be running?

For the Steam Tools copy, Steam has to be running for updates but the server starts without it as long as SteamAppId is set. A SteamCMD install never needs the client.

Is it safe to close the server window?

No. Closing the window kills the process without saving. Press Ctrl+C in it and wait for the save, or stop the NSSM service, which sends Ctrl+C for you.

Can I run two Valheim servers on one Windows machine?

Yes, with separate world names, separate -port values at least three apart (2456 and 2466 is common), and separate firewall ranges. Two NSSM services with different names handle the rest.