Sons Of The Forest

Sons Of The Forest

175 ratings
Dedicated Server Configuration Guide
By Dishmink and 1 collaborators
This guide explains how to configure a dedicated game server using a JSON configuration file and command line arguments. It covers topics such as server ownership, configuration file creation, gameplay settings, and overriding parameters with command line arguments. The guide also includes information on making the server available to the internet by configuring port forwarding and firewalls.
16
5
2
3
5
2
4
4
2
3
2
   
Award
Favorite
Favorited
Unfavorite
How to install the Dedicated Server
The game server can be downloaded from Steam directly (logged in), or completely anonymously (no Steam account needed) via SteamCMD tool.


From Steam

The dedicated server will be available in the Tools section of your Steam library. You can also find it using the search bar.

https://steamuserimages-a.akamaihd.net/ugc/2023853171814015185/2633A6259C673B0F52BBF979D7FDD5CB0A723938/?imw=256&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false




Using SteamCMD

You can install the SteamCMD tool for Windows directly from Valve's website, available here: https://developer.valvesoftware.com/wiki/SteamCMD. This page also contains the complete documentation of the tool, but you shouldn’t require anything besides what’s in this guide to get started.

To install or update the game, start SteamCMD then type in (with modified install directory if needed, in our example we will install the server to c:/sons-dedicated):

force_install_dir c:\sons-dedicated\ login anonymous app_update 2465200 validate

For more advanced users, it is also possible to chain these commands by directly typing in Windows command line (or from a batch file). This could prove useful if you want to set up automatic auto-game updates for example.

steamcmd.exe +force_install_dir "c:/sons-dedicated/" +login anonymous +app_update 2465200 validate +quit
Making the Server available to the internet
In order to allow other players to connect to your server, you will have to make sure your machine is configured correctly to allow traffic on the 3 different ports listed below, and in the configuration file. The usual required steps are:

1. setting up the appropriate Port Forwarding rules on your router or hosting service
2. setting up the appropriate rules in your operating system Firewall, and/or in your router/switches built-in firewalls

Required Ports:

  • GamePort (UDP): 8766
  • QueryPort (UDP): 27016
  • BlobSyncPort (UDP): 9700

These ports are the default ports and can be changed in the configuration file that is going to be discussed in the coming paragraph.

Starting the dedicated server
The game server can be started from the file named “StartSOTFDedicated.bat” in the install folder, or via the Steam launcher if you installed the dedicated server from Steam directly.
Self Test Procedure
When booting, the game server runs a self-test procedure that will check if your server is properly configured.

This procedure is a tool to help server admins get immediate feedback about the validity of their game server (whether it is in terms of configuration or network accessibility), and make sure the creation of a dedicated game server is as user friendly as possible.

If the self test fail, the server won’t start. The reason for the self test failure is always visible in the console or logs, and will pinpoint the issue. The reasons could be:

Error
Resolution
Server configuration doesn't exist. A default one has been created automatically.
After the first run, a default config file is created in the <user data folder> if it doesn’t exist, you can tweak it if necessary (see Configuration file section), then restart the server.
Server owners whitelist doesn't exist. A default one has been created automatically.
After the first run, a default server owner file is created in the <user data folder> if it doesn’t exist, you can tweak it if necessary (see Server ownership section), then restart the server.
Game settings couldn't be deserialized
Make sure SonsGameSettings.cfg in <user data folder> is in a valid JSON format, if you changed it manually, undo your changes, or delete the file (you will lose your in-game settings like key bindings, graphics settings, etc…).
The configuration couldn't be read without error. The Dedicated Server configuration file is invalid.
Make sure dedicatedserver.cfg in <user data folder> is in a valid JSON format (see Configuration file section for more details).
<some error about the values>. Dedicated Server configuration file is invalid.
Make sure that your settings are in the range of allowed values, the console will show you exactly which setting causes the failure.
Failed to get public ip from Steam.
Your public IP couldn’t be retrieved from Steam servers, make sure you have a valid static public ip v4.
UDP <PortName> <PortNumber> is closed.
Check your port forwarding, check your firewall, check your network settings



Failing any one of these tests will stop the server boot sequence. You can shut down the server, fix the issue, and restart.

If the network accessibility test fails (IPv4 address retrieval and port checking procedure), the server won’t start. In such cases, you have 3 options:

1. Fix your network configuration and port forwarding
2. Setup the “LanOnly” flag discussed below (see. Exposing a game to LAN), which basically excludes your game from the public listing
3. Expert Only ⇒ Skip the network accessibility test procedure (this is the only skippable test procedure). This is likely to be your only option if your ISP/Modem configuration doesn’t support NAT Loopback/Hairpin NAT as this is blocking the server from auto-testing itself using the public IP address.


Even though skipping the network accessibility test is possible with the “SkipNetworkAccessibilityTest” setting, and sometimes the only solution (NAT Loopback/Hairpin NAT not supported by your network setup), please note that it is not recommended as it is very likely that a server that doesn’t pass the test won’t be accessible anyway. If you decide to skip the procedure, make sure you check the availability right away in-game in the Dedicated server browser. If skipping the network accessibility test doesn’t help, we recommend setting it back to false.



If your network doesn’t support NAT Loopback/Hairpin NAT, then be aware that:

  • your server may not be visible in the dedicated server browser if you’re running the game in the same LAN as the server, or on the same machine as the server
  • the server can only be joined from the LAN browser
Exposing a game to LAN
When making a game available to LAN, you’ll have to consider the following.

  • you may want to optionally set the "LanOnly" flag to true if you want to hide your game from the internet search

  • in LAN, you shouldn’t need any port redirection if you are running in the same network as the other clients, however you will still have to set up your firewall appropriately

  • your local network has to be trusted by your operating system and allow traffic, in order to do this, your Network Profile has to be Private

  • there is a known issue when you have multiple network adapters, in some cases Steam will pick up the wrong one to do LAN games discovery and yield no result. If you have any issue, this can be confirmed by temporarily disabling all other network interfaces, and trying again
User Data Folder
When running the dedicated server, it will be using a persistent user data folder for:

  • reading configuration files
  • saving and loading the game saves
  • writing server logs
  • etc…

This folder can be either configured to a particular directory, or left to default. The default place where the user data is stored is
C:\Users\<user>\AppData\LocalLow\Endnight\SonsOfTheForestDS

It can be overridden using a command line argument:
-userdatapath "c:/path/to/directory"
If no argument is specified, the default directory will be used.


Throughout this guide, we will make reference to this folder as <user data folder>

Where to find the Configuration Files
All configuration files that will be discussed later in this document can be found / must be located in the game <user data folder> as described in the previous section.

This folder will contain:

  • the server owners list, in a file called ownerswhitelist.txt
  • the game server configuration, in a file called dedicatedserver.cfg
  • the saves (if the path is not overridden), in a folder called Saves
  • the game settings, in a file called SonsGameSettings

Note that these files do not exist right away after the installation, the game has to be started once for the default files to be created. Not all of these files need intervention to set up the dedicated server.

You should only need to touch:

  • ownerswhitelist.txt
  • dedicatedserver.cfg
Server Ownership
In order to be able to administrate your server from in-game directly, you will need to set up server ownership using the ownerswhitelist.txt file. This will allow you, as a player, to have full access to the in-game administration panel (Pause Menu / Players) where you will be able to:

  • upgrade other players to administrators
  • downgrade other players to guests
  • kick guests
  • ban and unban guests

How to create the default server ownership file

When first starting the server, the default configuration file will be created in the configurations folder, if it doesn’t exist already. You can either create it like this, or simply create a txt file as described in the following sections.

File name and format

In order to set up server ownership you will have to feed in the steam ids of all “server owners” in the file called ownerswhitelist.txt, one steam id per line. When first starting the server, the default configuration file will be created in the configurations folder, if it doesn’t exist already.

Server owners have essentially the same rights as P2P server hosts, it’s the highest role and gives access to all commands, so make sure to only add trusted people to this list. Below is an example file.

# In order to be able to administrate your server from in-game directly, you will need to setup server ownership. # Add below the steam ids of every server owner, one steam id per line. # To find your SteamID, open Steam and click on your name on the top right, then go to Account Details. # Jane Doe 7987654321987 # John Doe 7123456789123


To find your SteamID, you can either navigate to this page https://store.steampowered.com/account/ or directly in Steam click on your name on the top right, then Account Details.
Configuration File
The dedicated game server can be configured with a JSON file in the configurations folder, called dedicatedserver.cfg

How to create the default configuration file

When first starting the server, the default configuration file will be created in the configurations folder, if it doesn’t exist already. You can either create it like this or simply create a JSON file as described in the following paragraph.

File name and format

Our configuration file is written in JSON format. You can find online a multitude of resources that can teach you how to deal with such files. We will list below some basic mistakes when editing JSON files:

  • keys are always written in quotation marks and followed up by a semicolon
  • a textual value will always be written in between quotation marks “the text”
  • integers, floating point values, and boolean (true/false), will be written without quotation marks
  • each setting (key-value pair) must be followed up by a comma (,)

Notes:

  • some settings can be set to null, which means that they have no value. The outcome depends on the settings and is described in the documentation below
  • no setting is mandatory, if the setting doesn’t exist it will be replaced by its default value
  • the order doesn’t matter

The file name has to be dedicatedserver.cfg and contains a JSON formatted document that defines all parameters related to the game server configuration. It has to be placed in the configurations folder. Below is the default file.

{ "IpAddress": "0.0.0.0", "GamePort": 8766, "QueryPort": 27016, "BlobSyncPort": 9700, "ServerName": "Sons Of The Forest Server (dedicated)", "MaxPlayers": 8, "Password": "", "LanOnly": false, "SaveSlot": 1, "SaveMode": "Continue", "GameMode": "Normal", "SaveInterval": 600, "IdleDayCycleSpeed": 0.0, "IdleTargetFramerate": 5, "ActiveTargetFramerate": 60, "LogFilesEnabled": false, "TimestampLogFilenames": true, "TimestampLogEntries": true, "SkipNetworkAccessibilityTest": false, "GameSettings": {}, "CustomGameModeSettings": {} }

Key
Effect
Accepted Values
IpAddress
Listening interface for the game server, usually 0.0.0.0 if listening on all interfaces.
any string formatted ipv4 address
GamePort
UDP port used for gameplay netcode.
integer
QueryPort
UDP port used by Steam to list the server and enable the discovery services.
integer
BlobSyncPort
BlobSyncPort UDP port used by the BlobSync system to initialize game systems and exchange data.
integer
ServerName
Name of the server visible in the server list, and in the Steam contacts.
any string
MaxPlayers
The maximum number of players allowed simultaneously on the server.
integer (1-8)
Password
Adds a password to make your server “private”. Upon connection, this password will be requested before the client can proceed.
any string up to 40 characters long
LanOnly
Allows or restricts the server visibility to LAN only.
true, false
SaveSlot
When creating a new save, this number will be the id of the save.
integer greater or equal to 1
SaveMode
Game save initialization mode.
“continue”: will create a new save on SaveSlot if it doesn’t exist, or load it if it exist.
“new”: will create a new game, with a new game id, and overwrite any game previously saved on the SaveSlot. If the server stops and restarts, the previous save will be overwritten for as long as the mode is set to “new”.
new, continue
GameMode
Sets the difficulty game mode when creating a new save. This parameter is ignored if loading a save (save mode set to “continue” with a save that exists on the slot). If the game mode is set to “custom”, then the custom game mode settings will be read from CustomGameModeSettings option, described later.
normal, hard, hardsurvival, peaceful, creative, custom
SaveInterval
How often the game server automatically saves the game to SaveSlot, in seconds.
integer
IdleDayCycleSpeed
A multiplier to how quickly the time passes compared to normal gameplay when the server is considered idle (no player connected).
floating point value between 0 and 1, greater than or equal to 0
IdleTargetFramerate
Target framerate of the server when it’s considered idle (no player connected).
integer greater or equal to 1
ActiveTargetFramerate
Target framerate of the server when it’s NOT considered idle (one or more player connected).
integer greater of equal to 10
LogFilesEnabled
Defines if the logs will be written to files. The logs will be output in <user data folder>/logs.
true, false
TimestampLogFilenames
Enabled log files timestamping.
“true”: every time the server runs will dump log output to a new file, with filename having the following format: sotf_log_{DateTime:yyyy-MM-dd_HH-mm-ss}.txt
• “false”: the filename will be sotf_log.txt and previous log will be overwritten if it already exists.
true, false
TimestampLogEntries
Enables each log entry written to file to be timestamped.
true, false
SkipNetworkAccessibilityTest
Opt-out of network accessibility self tests: retrieval of the public IP and listing on Steam Master Server, as well as port accessibility check. Please note that only IPv4 is officially supported.
true, false
GameSettings
A key value map of all game settings you can use to tweak your game (in any mode). All parameters will be listed in a later paragraph along with their possible values. If the value is null, or empty, default settings will be used.
Refer to Game Settings section
CustomGameModeSettings
A key value map of all settings available to customize your game in custom mode. All parameters are listed later in this guide along with their possible values. If the value is null, or empty, default settings will be used. This parameter is ignored if the game mode is not “custom” or if loading a save (save mode set to “continue” with a save that exists on the slot), whether is it “custom” or not.
Refer to Custom Game Mode Settings section

Game Settings
These are extra settings that can be injected in the configuration file inside the “GameSettings” parameter.


"GameSettings": { "Gameplay.TreeRegrowth": true, "Structure.Damage": true },

Key
Effect
Accepted Values
Gameplay.TreeRegrowth
Enable automatic tree regrowth, triggered when sleeping.
true, false
Structure.Damage
Allow buildings to be damaged.
true, false

Custom game mode settings

These are extra settings that can be injected into the configuration file inside the “CustomGameModeSettings” parameter. They will be ignored if the game mode is not “custom” or if loading a save (save mode set to “continue” with a save that exists on the slot), whether is it “custom” or not, since they are set once upon save creation.

"CustomGameModeSettings": { "GameSetting.Multiplayer.Cheats": false, "GameSetting.Multiplayer.PvpDamage": "Normal", "GameSetting.Vail.EnemySpawn": true, "GameSetting.Vail.EnemyHealth": "Normal", "GameSetting.Vail.EnemyDamage": "Normal", "GameSetting.Vail.EnemyArmour": "Normal", "GameSetting.Vail.EnemyAggression": "Normal", "GameSetting.Vail.AnimalSpawnRate": "Normal", "GameSetting.Vail.EnemySearchParties": "Normal", "GameSetting.Environment.StartingSeason": "Summer", "GameSetting.Environment.SeasonLength": "Default", "GameSetting.Environment.DayLength": "Default", "GameSetting.Environment.PrecipitationFrequency": "Default", "GameSetting.Survival.ConsumableEffects": "Normal", "GameSetting.Survival.PlayerStatsDamage": "Off", "GameSetting.Survival.ColdPenalties": "Off", "GameSetting.Survival.StatRegenerationPenalty": "Off", "GameSetting.Survival.ReducedFoodInContainers": false, "GameSetting.Survival.SingleUseContainers": true, "GameSetting.Survival.BuildingResistance": "Normal", "GameSetting.Survival.CreativeMode": false, "GameSetting.Survival.PlayersImmortalMode": false, "GameSetting.FreeForm.ForcePlaceFullLoad": false, "GameSetting.Construction.NoCuttingsSpawn": false, "GameSetting.Survival.OneHitToCutTrees": false }

Key
Effect
Accepted Values
GameSetting.Multiplayer.Cheats
Allows cheats on the server.
true, false
GameSetting.Vail.EnemySpawn
Enable enemies spawning.
true, false
GameSetting.Vail.EnemyHealth
AAdjust enemy starting health.
low, normal, high
GameSetting.Vail.EnemyDamage
Adjust damage enemies can do.
low, normal, high
GameSetting.Vail.EnemyArmour
Adjust enemies armor strength.
low, normal, high
GameSetting.Vail.EnemyAggression
Adjust enemy aggression level.
low, normal, high
GameSetting.Vail.AnimalSpawnRate
Adjust animal spawn rate.
low, normal, high
GameSetting.Vail.EnemySearchParties
Adjust the frequency of enemy search parties.
low, normal, high
GameSetting.Environment.StartingSeason
Set environmental starting season.
spring, summer, autumn, winter
Structure.Damage
Allow buildings to be damaged.
true, false
GameSetting.Environment.SeasonLength
Adjust season length.
short, default, long, realistic
GameSetting.Environment.DayLength
Adjust day length.
short, default, long, realistic
GameSetting.Environment.PrecipitationFrequency
Adjust the frequency of rain and snow.
ow, default, high
GameSetting.Survival.ConsumableEffects
Enable damage taken when low hydration and low fullness.
normal, hard
GameSetting.Survival.PlayerStatsDamage
Enable damage from each bad or rotten food and drink.
off, normal, hard
GameSetting.Survival.ColdPenalties
Adjusts the severity that cold will affect health and stamina regeneration.
off, normal, hard
GameSetting.Survival.StatRegenerationPenalty
Reduces the rate that health and stamina will regenerate.
off, normal, hard
GameSetting.Survival.ReducedFoodInContainers
Reduces the amount of food found in containers.
true, false
GameSetting.Survival.SingleUseContainers
Containers can only be opened once.
true, false
GameSetting.Survival.BuildingResistance
Adjust building resistance to attacks.
low, normal, high
GameSetting.Survival.CreativeMode
Enable creative mode game.
true, false
GameSetting.Survival.PlayersImmortalMode
Enable god mode for all players.
true, false
GameSetting.FreeForm.ForcePlaceFullLoad
If true, everything players have in hands will be placed in a single click (stones, stone floors, wood floors)
true,false
GameSetting.Construction.NoCuttingsSpawn
If true, disable cuttings spawning.
true, false
GameSetting.Survival.OneHitToCutTree
Enable chopping tree with a single hit.
true, false
Special Cases
  • if a parameter is missing from the config, the default value is used
  • if the game runs without a config file, the default configuration is used
  • all parameters can also be overridden by a command line argument (see paragraph below)

Overriding parameters with command line arguments

Every parameter listed in the configuration file can be overridden via the command line to allow more flexibility. You can even create the full configuration via command line if you want to. The format goes as below:

SonsOfTheForestDS.exe -dedicatedserver.<parameter> "<value>" # For example SonsOfTheForestDS.exe -dedicatedserver.ServerName "My Custom Server" -dedicatedserver.MaxPlayers "4"
Configuring the server logging verbosity
The verbosity of the game server logs can be configured by using the command line argument “-verboseLogging”. By default, the game server will run in non verbose mode and will show a minimal amount of information in the console and in the log files (if “LogFilesEnabled” is true).

Full verbose logging can be forced by:

  • launching the dedicated server from steam launcher with Launch Option -verboseLogging
  • executing “StartSOTFDedicated.bat” with the -verboseLogging argument
  • or editing/cloning “StartSOTFDedicated.bat” and changing “set VerboseLogging=false” to “true”

Keep in mind that if you decide to edit “StartSOTFDedicated.bat” (or any game file in the install folder), the changes will be overwritten to the default file at the next dedicated server install verification/update.

In normal conditions, you shouldn’t need to enable verbose logging as it increases the log sizes unnecessarily. However, it can be useful to temporarily enable it to create better reports if you have issues.
217 Comments
GꝏmbaGurl Sep 5 @ 11:15pm 
Does anyone know if the overriding parameters can be used to create a dedicated server allowing more than 8 players? Or is this limited by the hardcode of the game? I realize it requires a powerful server to have more than 8 players, but it'd be nice if the resources are available.
I hate how they do not support IPV6. I am sitting behind a CGNAT so Ipv4 is out of question, but I do have a public v6 which lets me host Minecraft and Factorio servers...
Clayton Jun 29 @ 9:17am 
GameSettings Are there the latest parameters.
Crazymine Jun 2 @ 10:43am 
@ReadyPlayerOne
JSON can differentiate between different data types.
true/false belong to a special type (boolean) that only allows these values. They cannot be put inside quotes, as that would change the type to text.
The other value is a text value. JSON requires texts to be put inside quotes.
The values should not be case-sensitive.
ReadyPlayerOne Apr 23 @ 4:24pm 
I notice some values have quotes and others don't. Is that a typo or do some require quotes and others no quotes? Example:
"GameSetting.Multiplayer.Cheats": false,
"GameSetting.Multiplayer.PvpDamage": "Normal",
The false has no quotes, the normal does have quotes. Also, are the values case sensitive?
Appa Mar 27 @ 3:59pm 
is that a typo in the table? GameSetting.Environment.PrecipitationFrequency *ow* should be *low*?
小H酱哦 Mar 11 @ 10:57am 
I am not good at using machine translation in English, please understand!
小H酱哦 Mar 11 @ 10:54am 
PS:
The server will automatically perform network detection upon startup. By capturing packets, it is discovered that network detection is actually verifying whether the server's public IP address and port can be accessed by accessing the network address in "./configure/config. vdf"; If a proxy network is used, the server's detection address becomes the address of the proxy server, which naturally prevents normal access to the built server through the public IP, but is not affected in the local area network; I think this is probably because most people start up the server but can join it within the local LAN, while others cannot access it through the WAN;
After shutting down the proxy, you may encounter the problem of not being able to obtain the public IP, and the server cannot start. In fact, this is where the server is conducting network detection; If the network configuration is correct, use "SkipNetworkAccessibility Test": true in the configuration to skip network detection.
小H酱哦 Mar 11 @ 10:50am 
Solution:
Firstly, it is necessary to confirm that the following points are correct:
1. Configure the server configuration file correctly; (Refer to official documentation)
2. The listening address and port are correct; (IP: 0.0.0.0, GamePort: 8766, QueryPort: 27016, BlobSyncPort: 9700)
3. Set LanOnly to false in the configuration;
4. Confirm that the port mapping is configured correctly; (Please configure according to the router settings);
5. Use "SkipNetworkAccessibilityTest" in the configuration file: true to skip network detection
6. Please disable the network proxy of the server, or configure 'steamserver. net' as a direct connection in the proxy rules and do not use proxies;
小H酱哦 Mar 11 @ 10:50am 
When setting up a server, many people may have encountered a headache: they can join the server within their local LAN, but others cannot access it through the wide area network. Even if they try to connect to this server by searching on Steam server, it will indicate that they cannot connect. I also encountered the same problem when setting up the server. By using logs to determine and view server files, and even capturing packets, I found some solutions to this problem and shared them with everyone for reference.