Guides/Don’t Starve Together Dedicated Servers

From Don't Starve Wiki
Jump to navigation Jump to search
Icon Books.png This article may contain instructional language and subjective recommendations. Readers should read the content carefully, and follow accordingly.

The dedicated server is a component of Don't Starve Together (DST) that handles the game logic, without any of the graphics related logic. The same server software may be run standalone by a user directly, or run by the game client through the in-game Host server menu. The former case is what people generally refers to when saying "dedicated server", that is a standalone DST server that will not shutdown even if no player is online. In this article, unless otherwise specified, "dedicated server" is always going to refer to former case.

For a quick start setup, see #Klei's Website Server Generator. For a simpler guide to setting up a dedicated server through Steam on a normal computer, see Guides/Simple Dedicated Server Setup.

Requirements

The server software itself can be installed without owning the game. You must own a copy of Don't Starve Together to host online dedicated servers, but offline servers does not have this requirement. A single copy of DST can host any number of online dedicated server instances.

Dedicated servers use the same underlying networking infrastructure as client hosted servers since they are the same software. NAT-traversal and relaying will happen automatically if a client cannot establish a direct connection to a dedicated server[1].

Klei Entertainment Inc. only provides builds of dedicated server for Windows and Linux, both x86 and x86_64 (32 and 64 bits). Non-x86 hardware is not officially supported.

Installation

Downloading through SteamCMD

Download and install SteamCMD per Valve's instructions at https://developer.valvesoftware.com/wiki/SteamCMD#Downloading_SteamCMD.

Start SteamCMD , and run the following commands:

login anonymous
force_install_dir /path/to/installation/directory
app_update 343050 validate

Use the same commands for updating the game.

Adding validate like above causes Steam to perform the equivalent of "Verify integrity of game files" in the Steam GUI, removing any files not belonging to the game. Omitting this option may be desirable if mods have been installed, since Steam would remove them during this process.

Downloading through Steam GUI

If you own Don't Starve Together on Steam, a "Don't Starve Together Dedicated Server" item will appear in the 'tools' subsection of your library. Install it same as a normal game. Right click > Manage > Browse local files to view the install location. This will create the exact same set of files as installation using SteamCMD.

Configuration

This section covers the mechanics of configuration a server in detail. See #Other Configuration Methods for automated or semi-automated processes of configuration.

An instance of a DST server runs in a cluster of shards. The dedicated server expects the cluster directory to contain one subdirectory for each shard. For example, a cluster named Cluster_1 have the following configuration files:

Cluster_1/
|- Master/                      # the shard folder for Forest
|  |- server.ini
|  |- worldgenoverride.lua
|  |- leveldataoverride.lua
|  \- modoverrides.lua
|- Caves/                       # the shard folder for Caves
|  | ...                        # same files as Master/
|- cluster.ini
|- cluster_token.txt
|- adminlist.txt
|- whitelist.txt
\- blocklist.txt

cluster.ini and server.ini

Both files are mandatory. The whole cluster gets a single shared cluster.ini, and each shard gets its own server.ini. Refer to https://forums.kleientertainment.com/forums/topic/64552-dedicated-server-settings-guide/ for the available options in these two files.

cluster_token.ini

This file contains a cluster token and is necessary only if you want to run an online server. Omit this file if you have configured the server to be offline. A cluster token proves ownership of Don't Starve Together and allows Klei to moderate servers that violate their terms of service.

Generate Using Klei's Website

Navigate to https://accounts.klei.com/account/game/servers?game=DontStarveTogether, fill out the Cluster Name text box at the bottom of the page, and click Add New Server. The cluster token will be displayed in a list, copy it into cluster_token.txt. The cluster name and other options inside the Configure Server menu are only relevant for the website's server generator, they do not have to match the actual configuration of the cluster you are running.

Generate Using In-Game Console

Press tilde (~) (or ù on Azerty keyboards) in the game client to open the developer console. Execute this command:

TheNet:GenerateClusterToken()

This command will generate the cluster token under the name cluster_token.txt that contains the cluster token. This file located in

  • On Windows: %USERPROFILE%/Documents/Klei/DoNotStarveTogether/cluster_token.txt
  • On Linux: ~/.klei/DoNotStarveTogether/cluster_token.txt
  • On macOS: ~/Documents/Klei/DoNotStarveTogether/cluster_token.txt

Admin, Whitelisting, and Blacklisting Players

adminlist.txt lists players who are admins, whitelist.txt lists players who are whitelisted, and blocklist.txt lists players who are blacklisted. All of the files are optional. All of the files have the same format, where each line contains a User ID.

  • If adminlist.txt is omitted or left empty, for online severs, the only admin will be the player whose User ID is associated with the cluster token. In offline servers, no players will be admin.
  • If blocklist.txt is omitted or left empty, no player is blacklisted.
  • If whitelist.txt is specified, there should be exactly as many players specified as the NETWORK.whitelist_slots option in cluster.ini. Each whitelisted player is reserved a slot out of the max number of players so that they can always join. There is current a bug that causes only the last listed User ID to be respected.

For online servers, players' User ID will be their Klei account ID in the form of KU_XXXXXXXX where X can be [A-Za-z0-9_]. For offline servers, players' User ID will be in the form of OU_YYYYYYYYYYYYYYYYY where Y is a digit. There are many ways of obtaining User ID, here are a few and use the search engine for more:

[00:00:20]: [Shard] Read save location file for (KU_XXXXXXXX)

World Generation and Settings

World generation and world settings are controlled by the combination of worldgenoverride.lua and leveldataoverride.lua. At least one needs to be specified. worldgenoverride.lua is the nicer, more human readable file intended to be used by server admins. leveldataoverride.lua is used internally by the DST client to store world settings, and may be used in a dedicated server if desired but is not recommended. If both files are present, the contents of leveldataoverride.lua will override that of worldgenoverride.lua[2].

worldgenoverride.lua has the following format[3]:

return {
  override_enabled = true,
  -- <preset name> can take one of these values:
  -- "SURVIVAL_TOGETHER", "MOD_MISSING", "SURVIVAL_TOGETHER_CLASSIC", "SURVIVAL_DEFAULT_PLUS", "COMPLETE_DARKNESS", "TERRARIA", "DST_CAVE", "DST_CAVE_PLUS", "TERRARIA_CAVE"
  -- Settings this equivalent to setting both "worldgen_preset" and "settings_preset"
  preset = "<preset name>",
  -- Set these two if you switch to use separate presets for worldgen and world settings
  worldgen_preset = "<preset name>",
  settings_preset = "<preset name>",
  -- Options here will override that provided by the presets
  overrides = {
    -- Refer to the Klei article referenced above for all the available options
  },
}

leveldataoverride.lua has an unspecified format. It is recommend that you use the game client's Host server to configure a world, and copy the generated file into your dedicated server.

Modding

Mods needs to be installed and then enabled for it to be active. Installation is global to every dedicated server install, whereas enabling (and optionally mod configuration) is specific to every shard. In most cases, every shard of a cluster should enable the same set of mods and use the same set of mod config options to avoid incompatibilities.

Installing Mods

Mods can either be installed declaratively with dedicated_server_mods_setup.lua or manually. The former is the recommended and most convenient way to install mods on Steam Workshop. For mods not published on Steam Workshop, you must install them manually. Each mod will be assigned a mod name that is used to enabling and configuration, take note of it. Mod names vary depending on which method you choose to install, and is italicized in this section.

dedicated_server_mods_setup.lua

This method supports either installing individual Steam Workshop mods, or all mods in a Steam Workshop collection.

Each installed mod will have its mod name be workshop-ITS_OWN_WORKSHOP_ID, regardless of being installed individually or through a collection. When the dedicated server process starts, it will automatically download and update all mods listed in this file (unless prohibited by the #-skip_update_server_mods command line option). The mods only update when the version changes on Steam Workshop, so server boot times should be reasonable and only pickup mod changes as they get posted to the Workshop.

Installing Mods Manually

To install a mod manually, create a directory under the mods/ in the dedicated server install, and then place mod files in it. The name of the directory you create determines the mod name and is completely up to you: it does not have to match what the mod calls itself.

Mod files should at least have a modmain.lua and modinfo.lua, and may additionally include scripts/, anim/, main/, etc. (the list is not exhaustive). If you do not see these files, then it's likely that are you looking at the wrong directory of a mod, or it's not a mod at all! For example, in a dedicated server isntalled on Windows in Steam's default location, a mod installed manually might look like this:

C:/Program Files (x86)/Steam/steamapps/Don't Starve Dedicated Server/mods
|- mods/
|  |- my_awesome_mod/
|  |  |- modinfo.lua
|  |  |- modmain.lua
|  |  | ...
|  | ...
| ...

in which my_awesome_mod is the mod name.

Enabling and Configuring Mods

Mod enabling and configurination are done through each shard's modoverrides.lua file. This file is optional, omitting it simply enables no mod in the shard.

The file is a lua script that should return a table, where each element corresponds to a single mod. The key of the element is the mod name. The value is another table with a boolean element enabled and a table element configuration_options containing the mod's config options.

Take the example mod https://steamcommunity.com/sharedfiles/filedetails/?id=2902364746 installed using dedicated_server_mod_setups.lua. In the simplest case where you just want to enable the mod and use the default config, simply write:

 return {
+  -- Global Positions (-Remapped)
+  ["workshop-2902364746"] = { enabled = true },
 }

To configure it (using an example option):

 return {
   -- Global Positions (-Remapped)
-  ["workshop-2902364746"] = { enabled = true },
+  ["workshop-2902364746"] = {
+    enabled = true,
+    configuration_options = {
+      mode = "Eassy Cartography"
+    },
+  },
 }

Note: Using this method, dedicated servers (and the normal client) can override the mod config options to non-valid options that are normally not available through the in-game GUI. This may cause malfunctions because the mods are not designed with such config values in mind. Do so with caution.

Running

After a cluster is configured, the dedicated server executable needs to be invoked separately for each shard.

For a shard living at /path/to/servers/DST/Cluster_1/Master, run the following command:

./dontstarve_dedicated_server_nullrenderer.exe \
  -persistent_storage_root '/path/to/servers' \
  -conf_dir 'servers' \
  -cluster 'Cluster_1' \
  -shard 'Master'

Replace dontstarve_dedicated_server_nullrenderer.exe with whichever executable you plan to use. In general, the dedicated server obtains the path to the shard folder by concatenating the values to the above 4 arguments in the shown order. -conf_dir and -persistent_storage_root may be omitted and their respective default values will be used.

The executable expects its working directory to be its bin/ folder. For example, in a dedicated server installed on Windows in Steam's default location at C:/Program Files (x86)/Steam/steamapps/Don't Starve Dedicated Server/bin/dontstarve_dedicated_server_nullrenderer.exe, the server must be run as such:

cd "C:/Program Files (x86)/Steam/steamapps/Don't Starve Dedicated Server/bin/"
./dontstarve_dedicated_server_nullrenderer.exe <arguments>

Command Line Options[4]

-persistent_storage_root <storage_root>

Must be an absolute path. Setting the root directory of persistent storage. When the server runs, a file will be created as Agreements/DoNotStarveTogether/agreements.ini under here. This is concatenated with -conf_dir to obtain the prefix path to where clusters are stored. Default value:

  • On Windows: %USERPROFILE%/Documents/Klei
  • On Linux: ~/.klei
  • On macOS: ~/Documents/Klei

-conf_dir <conf_dir>

Must be a single path component (no slashes). Default value: DoNotStarveTogether.

-cluster <cluster>

Must be a single path component (no slashes). Set the name of the cluster directory that this server will use. The server will expect to find the cluster.ini file in <storage_root>/<conf_dir>/<cluster>/cluster.ini. Default value: Cluster_1

-shard <shard>

Must be a single path component (no slashes). Set the name of the shard directory that this server will use. The server will expect to find the server.ini file in <storage_root>/<conf_dir>/<cluster>/<shard>/server.ini. Default value: Master

-bind_ip <bind_ip>

Change the address that the server binds to when listening for player connections.

-port <port>

Value must be an integer between 1 and 65535. Force the server to use a specific port.

-steam_master_server_port <port_number>

Value must be an integer between 1 and 65535. Internal port used by steam. This option overrides following setting in server.ini. Make sure that this is different for each server you run on the same machine.

[STEAM]
master_server_port = <number>

-steam_authentication_port <port_number>

Value must be an integer between 1 and 65535. Internal port used by steam. This option overrides the following setting in server.ini. Make sure that this is different for each server you run on the same machine.

[STEAM]
authentication_port = <number>

-tick <tick_rate>

Value must be an integer between 15 and 60. This is the number of times per-second that the server sends updates to clients. Increasing this may improve precision, but will result in more network traffic. This option overrides the following setting in cluster.ini. It is recommended to leave this at the default value of 15. If you do change this option, it is recommended that you do so only for LAN games, and use a number evenly divisible into 60 (15, 20, 30).

[NETWORK]
tick_rate = <number>

-players <max_players>

Value must be an integer between 1 and 64. Force the maximum number of players allowed in the server. This option overrides the following setting in cluster.ini.

[GAMEPLAY]
max_players = <number>

-ugc_directory <ugc_mods_path>

Either an absolute path or a relative path from the server process's working directory. This specifies where V2 mods are installed[5]. Default value is to use SERVER_DIR/ugc_mods/<cluster>/<shard>. For client hosted servers, this is automatically set to STEAM_DIR/steamapps/workshop/content/322330. See #Sharing V2 Mod Install.

-console

Enable a command line console input mechanism. Allows you to execute privileged Lua directly in the server window.

-lan

Force the server into offline and LAN mode, overriding the options specified in cluster.ini. This is equivalent to the following:

[NETWORK]
offline_cluster = true
lan_only_cluster = true

-disabledatacollection

Disable data collection for the server. Klei require the collection of user data to provide online services. Servers with disabled data collection will only have access to play in offline mode[4].

-backup_logs

Create a backup of the previous log files each time the server is run. The backups will be stored in a directory called "backup" in the same directory as server.ini.

-skip_update_server_mods

Skip checking and updating mods, and launch the game directly. The server normally first tries to update mods, and then start the world.

-only_update_server_mods

Check and update mods only, and then immediately exit. The server normally first tries to update mods, and then start the world.

Online vs. Offline Clusters

An online server will appear in the server browser as long as it is not configured to be LAN only. Players in an online server will receive skin gifts for the amount of time played. An offline server will not appear in the server browser, and players will receive no skin gifts.

Whether or not a server is online is governed solely by the offline_cluster option in cluster.ini. Online clusters must have a cluster_token.txt, otherwise the server will refuse to run. Offline clusters ignore cluster_token.txt even if it is present.

Clusters and Shards

An instance of a DST server runs in a cluster of shards. A shard is a server process running a specific world, which in vanilla can either be the Forest or the Caves. A cluster always consists of exactly one master shard and any number of secondary shards, where conventionally the master shard runs Forest and the single secondary shard runs Caves.

V1 and V2 Mods

Don't Starve Together's mod format had two revisions, called V1 and V2, also known as UGC mods. In the March 2021 QoL update, a new mod uploading tool is introduced along with the V2 mod format. To the end user, V1 and V2 have no functional difference; all mods using the new tool (even if the mod itself is exactly the same) will be V2 mods.

V1 and V2 mods vary in their installation location. V1 mods are installed in the mods/ named as workshop-WORKSHOP_ID. V2 mods' default location is SERVER_DIR/ugc_mods/<cluster>/<shard>, that is, mods will be redownloaded for every shard you run[5]. For client hosted servers, the default location is STEAM_DIR/steamapps/workshop/content/322330. V2 mod installation location is configurable using #-ugc_directory <ugc_mods_path>. V2 mods are also named as workshop-WORKSHOP_ID, so this means you can always use the same string to refer to mods regardless of it being V1 or V2

Other Configuration Methods

Klei's Website Server Generator

Refer to the Klei forum post on for Windows, Linux, and macOS respectively.

Automated Installation via AMP

Creating a server using AMP

AMP is a popular game server management panel you can run on your own PC/server that supports Don't Starve Together and makes it easier to get the server going from its web interface. You can run it on both Windows and Linux.

Once you have AMP itself up and running (Tutorial and Guide), click "Create Instance" and then select "Don't Starve Together" from the list of games. Once you've done that, select "Create Instance".

After that, double click the new Don't Starve Together instance to manage it and select "Update" from the status screen. This will download the Don't Starve Together server and required files.

Once the download is complete you can hit Start and after a few moments the server will start up. Once the startup has completed you can connect as normal.

Tips and Tricks

Sharing V2 Mod Install

Specify -ugc_directory ../ugc_mods as an argument to the server executable to force all shards to use the same directory for V2 mods. By default, every shard will download its own copy of V2 mods, creating a massive waste of disk space and increasing startup time. Note this may cause race conditions between multiple server processes if they are launched at the same time, so consider also using -only_update_server_mods and -skip_update_server_mods to first update all mods at once, and then launch all the shards without updating mods.

Troubleshooting

The server is running correctly, but it still can't be seen

Confirm that the server is listed in https://dstserverlist.appspot.com. Users will have to manually update the listing at the bottom of the Browser servers page. If it's still not visible from inside the game client, it is possible that the client can't ping the server. Assure that you made sure to forward UDP traffic on port 10999 to their machine.

Account Failed (6): "E_EXPIRED_TOKEN"

If you get the error, verify that you saved the cluster_token.txt file with the cluster token correctly with no extra characters at the end of the file, even invisible ones.

libcurl-gnutls.so.4: cannot open shared object file

Install the package on your Linux distro which provides libcurl-gnutls. Be sure to select the right version of 32bit vs 64bit, depending on which version of the server executable you are running.

Other Notes

  • To find ones own dedicated server when searching in game, the LAN games option must be turned on, as the server is hosted on the same machine and/or network. This does not necessarily mean that it is a LAN game, only that it is running on the same machine and/or network.
  • A great recommendation is to use Notepad++ or another such suitable program for editing the code as it offers more options and is generally more helpful to edit these files than the basic notepad or similar word program as it is tailored to these files and coding.
  • As mentioned above in command lines, windows users can easily control their servers through the black screen by opening the properties of a shortcut to the server's executable and then typing -console at the end of the target line. i.e. (~\bin\dontstarve_dedicated_server_nullrenderer.exe -console)