Skip to content

Running the server

Ryan McAfee edited this page Sep 16, 2026 · 2 revisions

Running the server

What actually happens when you press Start, Stop or Restart, how the server process is tied to the app, and what the automatic restarts do. This is the detail behind the buttons on the Dashboard.

Starting

The Start button builds a command line from the profile's settings and launches valheim_server.exe with no window. The line looks like this:

-nographics -batchmode -name "Baka Gaijin" -port 2456 -world "Midgard"
-public 1 -savedir "C:\Users\you\AppData\LocalLow\IronGate\Valheim"
-saveinterval 600 -backups 4 -backupshort 7200 -backuplong 43200
-password "hunter2" -crossplay -modifier combat hard

Every value comes from the Settings screen. The whole line is written to the log with the password replaced by asterisks.

One environment variable is set, SteamAppId=892970, which is the Steam app id of the dedicated server. Process priority is raised to above normal.

Two launch flags are stripped out of Additional Launch Args if you type them, and it is worth knowing why. -demomode turns off all world saving, so every minute played would be thrown away when the server stops. -joinserverwithcharacter makes the game try to join a server instead of hosting one, which a dedicated server cannot do. -logFile is also refused, because it would take away the output stream BakaLoader reads to know what the server is doing.

That whole line is built when the session starts, and the running server keeps what it was launched with. Saving a setting while the server is running writes the file and leaves the live server alone. Everything on the Settings screen takes effect at the next restart instead, and since 1.0.8 any restart will do, because the relaunch reads the profile again on its way back up. See Settings.

Starting is refused while an update runs

From the moment a Valheim server update starts rewriting the install, Start and Restart are refused everywhere, with one sentence:

An update is running for this install. Wait for it to finish.

That is the Dashboard buttons, the header strip button, both palette entries, and the automatic paths: a scheduled restart, an empty server restart and a crash relaunch. It is enforced on both sides, so a reloaded page or a second window cannot get around it. See Updating the server.

The server cannot outlive the app

When BakaLoader starts the server it puts the process into a Windows job object created with the kill on close flag. When BakaLoader's process ends, by any route including a crash or Task Manager, Windows kills everything in that job.

That is why you do not end up with an orphaned valheim_server.exe eating 8 GB after BakaLoader closes. It is also the reason for the close guard below: a job object kill is instant, and an instant kill does not save the world.

Closing the app

If any server is still running when you close BakaLoader, you get a dialog rather than a close.

The heading reads "Vikings are still online" when someone is on, "The server is still running" when nobody is, or "Servers are still running" with more than one. When players are online the body starts with how many will be disconnected. Then either "The world will be saved and the server shut down gracefully before BakaLoader closes." or the plural version for several servers.

Buttons: Save & shut down and Cancel.

Choosing to shut down stops every server and waits, checking four times a second, for up to 60 seconds. That deadline is deliberate. A wedged server should not be able to trap you in a window that refuses to close. If anything is still running when the 60 seconds are up, the app closes and the job object takes the rest.

Closing during a server update is refused instead: "An update is running. BakaLoader will close when it finishes." It then closes by itself once the update is done. A second close click within ten seconds insists and closes anyway, unless steamcmd is writing files at that moment, which is the one thing that will not be cut short. steamcmd is also started outside the job object, so even a crash of BakaLoader leaves it running to the end rather than splicing two builds together.

A crash of BakaLoader itself skips all of that. The job object fires, the server dies immediately, and the world loses whatever was played since the last periodic save. That is the argument for a sensible save interval.

Stopping

Stop issues taskkill on the server process without /F. That is a close request, not a termination, which gives Valheim the chance to write a final save on its way down. It is not forceful on purpose, and it should stay that way.

There is no timeout after that request on this path. The process exits when it has finished saving.

Restarting

Restart stops the server and starts it again when it has fully exited. The launch guard runs again on the way back up, so a build that changed while it was down is still caught. See Server updates and the launch guard.

In the moment before the relaunch, the profile is read again. A setting saved while the server was running is in force when it comes back, and that holds for the automatic restarts as well as this button. If the saved settings cannot be read at all, the relaunch keeps the ones the server is already running and writes a line to the log rather than refusing to restart. While what is saved differs from what the live server started with, the condition bar carries a Restart pending row whose own Restart button runs this same countdown.

Every restart also checks whether a newer BakaLoader is waiting, and stages it when Auto-update BakaLoader is on. If one is staged, the restart is abandoned and every BakaLoader window closes, so the file swap starts from a stopped app and the new version comes up and starts the server itself.

That check refuses in two cases. Another window's server counts: nothing is staged while any server anywhere in the app is running, restarting or about to launch, not just the one in this window. A Valheim server update counts too, so while steamcmd is rewriting any profile's install the app will not replace itself either. See Multiple servers and Updating the server.

The countdown

If RCON is on and players are online, a restart warns them in game first.

An automatic restart (scheduled, empty server or crash recovery) warns at 30 minutes, 5 minutes and 1 minute.

A restart you pressed warns at 1 minute, 30 seconds and 10 seconds. A full hour of countdown on a button you just pressed would make the button feel broken.

The messages are:

Server restarting in 5 minutes!
Server restarting NOW!
Server restart cancelled.

If an automatic mod update is riding along, each message gains " (2 mod updates pending)".

Pressing Restart again during a countdown skips to the end: it sends "Server restarting NOW!" and restarts. Cancelling sends the cancelled message instead.

With RCON off there is no announcement. The restart just happens.

Each announcement takes the same single file lock every other command uses, so the roster's five second position poll can no longer land between the countdown reconnecting and sending, which used to be able to cut a warning off.

The one Restart button decides for itself: a countdown running means skip to the end, nobody online means restart now with no announcement, players online means run the 60, 30, 10 countdown.

Adopting a server that is already running

If BakaLoader finds a valheim_server.exe already running from the exe path this profile is configured for, it asks:

A Valheim dedicated server is already running (PID 15042).

This can happen if BakaLoader was closed without stopping the server, or if the server was started outside of BakaLoader.

Yes = Adopt this server (monitor and manage it) No = Kill it so you can start fresh

Adopting registers the process, puts it in the job object so it now dies with the app, and shows it as Running.

There are real limits. BakaLoader did not start that process, so it never got its output stream. Everything that comes from reading the log is unavailable for an adopted session: player joins and leaves, the save timings, the version banner, the crossplay join code. Players already connected are invisible to the roster. Crash auto restart is deliberately off for an adopted process, because relaunching it with settings it was not started with is not a safe assumption.

RCON is unaffected. Positions, broadcasts, kicks, heals and the rest all work over the network regardless of who started the process, as long as the port and password match.

So if you have been launching with a batch file, the cleaner path is to let BakaLoader launch it. Adoption is a recovery route, not the normal one.

If BakaLoader finds another live BakaLoader instead, it does not offer adoption at all. It explains that the other instance owns the server and offers one button to close this window.

The three automatic restarts

Restart when the server empties, restart on a schedule, and relaunch after a crash all live on the Settings screen, and all three go through the same guard a restart you pressed does. What each one waits for, and what happens when the guard holds one, is on Automatic restarts.

Two things this depends on

The server's own console output, which is where the roster, the save timings and the version banner all come from. The lines it looks for are listed on Log (Saga).

RCON, which is how every command reaches a running server. How that works, and the plugin that answers it, are on The bundled plugins.

Questions people ask

I closed BakaLoader and the server kept running. It should not. If it did, it was started outside BakaLoader. Open BakaLoader and it will offer to adopt or kill it.

Does Stop save the world? It asks the server to close rather than killing it, and Valheim writes a final save on the way down. A hard kill, including the job object firing after a BakaLoader crash, does not.

Can I run two servers at once? Yes, with separate profiles on separate ports. See Multiple servers.

Does a restart pick up a setting I saved while the server was up? Yes. The relaunch reads the profile again just before it launches, so the Restart button and the automatic restarts all come back on what is saved.

The restart countdown never appears in game. RCON is off, or the port or password do not match what the plugin is using. Check the Network card on the Dashboard for whether RCON is bound.

Why does it need a plugin at all? The dedicated server has no built in remote control. Everything remote goes through RCON, and RCON on Valheim comes from a plugin. BakaLoader ships its own so you do not have to hunt for three third party ones.

Clone this wiki locally