Guides/Don’t Starve Together Dedicated Servers

A Dedicated Server is an optimized version of Don't Starve Together that has been designed to be run for longer periods of time, with none of the graphical overhead.

The server is available through Steam and SteamCMD on both Windows and Linux.

Requirements
You must own a copy of Don’t Starve Together to host an online Dedicated Servers, however a single copy of Don’t Starve Together can host many Dedicated Server instances.

Dedicated Servers do not use the same punch-through technology that our client hosted servers use. You must add proper port forwarding for your server to be reachable by game clients. The server uses UDP traffic on port 10999 by default.

To create a reliable/performant Dedicated Server experience you will want to ensure that your system has the following properties:
 * Internet (Upload) = 8Kbytes / player / s
 * Ram =  around 65Mbytes/player
 * CPU?
 * VCRedist_2008 (x86)

Downloading the Software
We currently offer two methods of downloading our server.

Downloading through SteamCMD:
Learn more about SteamCMD here: https://developer.valvesoftware.com/wiki/SteamCMD

On Windows:
login anonymous force_install_dir C:\path\to\directory app_update 343050 validate

On Linux (Debian):
sudo dpkg --add-architecture i386 # If running a 64bit OS sudo apt-get update sudo apt-get install lib32gcc1   # If running a 64bit OS sudo apt-get install libgcc1      # If running a 32bit OS sudo apt-get install libcurl4-gnutls-dev:i386 sudo useradd -m steam chmod a+rw `tty` # Note those are backticks, not single quotes sudo su - steam mkdir ~/steamcmd cd ~/steamcmd wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz tar -xvzf steamcmd_linux.tar.gz ./steamcmd.sh login anonymous force_install_dir /home/steam/steamapps/DST (or whatever absolute path you want) app_update 343050 validate quit cd /home/steam/steamapps/DST/bin/ screen -S "DST Server" ./dontstarve_dedicated_server_nullrenderer /!\ If your debian server is stable, you will not be able to launch the server because of the old libc version. The error will be : ./dontstarve_dedicated_server_nullrenderer: /lib/i386-linux-gnu/i686/cmov/libc.so.6: version `GLIBC_2.15' not found (required by ./dontstarve_dedicated_server_nullrenderer) Here is a hacky workaround (using the git repo https://github.com/dgibbs64/linuxgameservers/tree/master/Insurgency/dependencies ) mkdir ~/dst_lib && cd ~/dst_lib wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libc.so.6 wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/libpthread.so.0 wget https://github.com/dgibbs64/linuxgameservers/raw/master/Insurgency/dependencies/librt.so.1 And to run the server : cd /home/steam/steamapps/DST/bin/ screen -S "DST Server" bash -c 'LD_LIBRARY_PATH=~/dst_lib ./dontstarve_dedicated_server_nullrenderer'

The server will start, then you can do CTRL-A D to throw it to the back ground. If you want to see it again, just type: screen -x DST

Downloading through Steam (Only on Windows or “Desktop Linux” = requires a GUI):
If you own Don’t Starve Together, the Dedicated Server download will appear in the ‘tools’ subsection of your library.

Server Tokens
In order to run a public Dedicated Server, you are required to enter your “server token”. This token proves ownership of Don’t Starve Together and allows us to moderate servers that violate our terms of service.

To generate a server token, do the following:

Run Don’t Starve Together. Click Play Multiplayer.

Press tilde (~) (or ù on Azerty keyboards) to open the developer console and type: TheNet:GenerateServerToken The server token is written to your server_token.txt file located in:

On Windows: /My Documents/Klei/DoNotStarveTogether /server_token.txt On Linux: ~/.klei/DoNotStarveTogether/server_token.txt    Add your server_token.txt file to your custom configuration directory in order to authenticate the log-in credentials. 

Do not simply copy & paste the contents of this file from one machine to another. Move the actual file from one machine to another. If the file contains a carriage return or line ending at the file, you will receive an authentication error. 

Running
 Windows: dontstarve_dedicated_server_nullrenderer.exe [-conf_dir ] Linux: ./dontstarve_dedicated_server_nullrenderer [-conf_dir ] Please note that on Linux you MUST change your current directory to be that of the dedicated server executable.

Configuration
 The main method for configuring your dedicated server is through the settings.ini file.

On Windows: Documents/Klei/DoNotStarveTogether/Settings.ini On Linux: //.klei/DoNotStarveTogether/settings.ini Settings are divided by different categories,  make sure to put your changes under the appropriate category:

[network]
 default_server_name = Your unique server name d efault_server_description = A very nice server description  server_port = 10999  server_password = password  max_players = 1 .. 64  pvp = true | false  game_mode = endless | survival | wilderness Snapshots allow you to full roll back a server to an older state. This feature is pretty new and has been observed to cause problems on some servers. I have been disabling this on most of my servers right now.  enable_snapshots =true | false The auto saver creates a save at the start of each day, which will be resumed from when your server restarts.  enable_autosaver = true | false Tick rate determines the quality of your server. A higher tick rate consumers more bandwidth and CPU, but can result in smooth gameplay for clients.  tick_rate = 30 [ 10 | 15 | 30 | 60 ] A time in milliseconds that we should wait before dropping a non responsive client.  connection_timeout = 8000 Which save slot should the dedicated server load  server_save_slot = 1..5 When no admin is present, vote kick allows users to vote to kick players that are disrupting the game. enable_vote_kick = true|false

When the dedicated server is empty, pause the sim. This is especially useful for private dedicated servers, when you want to resume where you left off with a group of friends. Defaults to false. pause_when_empty = [ true | false ]

[account]
Enable LAN only server: dedicated_lan_server = [ true | false ]

Command Line Options
Command line options override settings.ini options.

Force the server to use a specific port -port [1024 .. 65535]

Force the server to run at a specific tick rate -tick [15 .. 60]

Force the maximum number of players allowed in the server. -players [1 .. 64]

Force the server into lan mode. The server will not require token authentication, and will not appear in the server listings. Only users on the same network will be able to join. -lan

Force the server to load save and settings data from an alternative directory. -conf_dir DoNotStarveServerDirectory

Multiple Servers on the Same Machine
 If you wish to run multiple servers on the same machine, or have your server co-exist with the client, you will want to launch your server with an alternative configuration directory.

 To see an alternative configuration directory, you can launch the server (or client) with this command line argument (on Steam you can do this under Properties -> Set Launch Options): -conf_dir DoNotStarveServerDirectory  This would change your configuration directory to "Documents/Klei/DoNotStarveServerDirectory/" You will then have a unique set of save slots,  log.txt and settings.ini files.

Customizing the World Map
Currently there is no known way to generate custom map settings (world size, amount of precipitation, length of day, amount of beefalo, etc.) from the command line. To customize the world, you must generate a map using the Don't Starve Together graphical client.

Creating the Map
To create a custom map for a dedicated server, launch the Don't Starve Together client and select the option to Host Server on the server selection screen. Select a New Server save slot on the left side, noting the slot number (1 through 5, 1 on the top). If you have no New Server save slots, you must delete a server first. Once you have selected a slot, select the option to Edit World on the right.

On the Edit World options screen, select the world options for the new world you wish to run as a dedicated server. It is not necessary to save your settings as a preset, though you may do so if you wish to reuse the settings later. When finished, select the option to Apply the settings.

Back on the server creation screen, enter a world name and description. This is required, but note that these settings are overridden in the persistent server's settings.ini file, so enter any legal values. The server will briefly appear in Klei's server selection screen, so please do not choose a vulgar or obscene name. Once ready, select the Create Server option on the left.

You will then see the Generating World screen while the map is generated, and next be placed on the character selection screen. At this point, the map is generated and there is no need to actually play on it, so select the option to Disconnect and confirm the option to shut down the server (Do it!) when prompted. You may now exit the Don't Starve Together graphical client.

In your Don't Starve Together directory, which is Documents\Klei\DoNotStarveTogether\save on Windows, or ~/.klei/DoNotStarveTogether/save on Linux, there will now be a file named survival_, where  is the save slot number noted above (for example, survival_2 for the second save slot).

Using your Custom Map on the Dedicated Server
There are several files in addition to the map that must be created or modified for the dedicated server to launch correctly. The easiest way to ensure that everything is appropriately set up is to first modify the settings.ini file to ensure that the save slot is set correctly, let the dedicated server generate a map, and then overwrite the map and restart the server.

In settings.ini, ensure that the server_save_slot parameter in the [Network] section matches up with the save slot number in the name of the world file. For example, if you are using survival_2, you should have this in your settings.ini file: [Network] server_save_slot = 2 Launch the Don't Starve Together dedicated server as you normally would, and once the server is running, stop it. In your configuration directory there should now be a save subdirectory that contains several file, including a survival_ file, where  is the slot number configured in settings.ini.

Copy the survival_ file to your dedicated server configuration directory overwriting the new generated file, renaming it if necessary, then relaunch the server. The dedicated server should now load your custom map.

Mods
Dedicated servers support mods now too, and can be automatically installed via servermods.lua in the main mods directory. This file is run on boot and will download any mods or collection of mods that are setup in the file. An example of this file would be. ServerModSetup("345692228") ServerModSetup("346968521") ServerModSetup("352373173") The mods only update when the version changes on the Workshop, so server boot times should be reasonable and only pickup mod changes as they get posted to the Workshop. These mods will be downloaded and installed to your mod folder, but they aren't enabled by default.

To enable mods on dedicated servers, there are two ways. The first is to force enable the mods. To do this you will need to modify the file modsettings.lua to force enable the mods you desire. For example this would enable three mods from the workshop. ForceEnableMod("workshop-345692228") ForceEnableMod("workshop-346968521") ForceEnableMod("workshop-352373173")  To ensure that clients will be able to download the corresponding mods from the Workshop, you must not change the mod directory names.

The second option is using a modoverride.lua file. Dedicated servers can now enable mods and set mod configurations via a file in the mod’s folder named “modoverride.lua” (\mods\your_mod\modoverride.lua). An example of the contents of this file is enabled = true configurtation_options = {    hunt_time = 6 } Note, dedicated servers (and normal clients) can override the mod config options to non-valid options using this method. In this example, 6 is not a normal option for the hunt_time in the Hunt game mode mod. This file will also not get deleted when a mod is updated on the dedicated server.

Administration
Dedicated servers can be remotely administered through the game client.

 The user who generated the server token is automatically granted administrator privileges.

An administrator has the ability to kick and ban users in the game, as well as to execute arbitrary lua on the server.

WARNING: Only grant administrator rights to those who you would trust with full access to your server / machine. We may add a moderator mode with reduced powers in the future.

 If you wish to provide administrator to additional users, you need to add an adminlist.txt file to your save directory:

NOTE: This file cannot have an extension.

On Windows: Documents/Klei/DoNotStarveTogether/Save/ On Linux: //.klei/DoNotStarveTogether/Save/   In this directory add the user identifiers for the users you wish to grant admin to. List the KU_’s one per line. 

As an admin, you may issue a remote command to your server by doing the following:  c_reset(true) - Deletes the current world and regenerates a new one. Pass false to reload the current world/ c_shutdown(true) - Saves and terminates the server application. Pass false to skip saving the world. c_spawn(“prefab name”) - Spawn something at the mouse position. c_give(“item name”) - Give an item to you. 
 * connect to the world through the game client
 * open the developer console (~)
 * press left CTRL to enter remote execution mode (REMOTE: appears to the left)
 * The command you enter will be executed on the server, assuming you have sufficient administrator rights

Is it possible to run my dedicated server in LAN mode?
Yes,  LAN mode can be configured in settings.ini by adding this line under the [account] heading: dedicated_lan_server = true '''Please remember LAN servers do not appear in the online server listings. '''

Is it possible to host multiple servers on a single (powerful) machine?
Yes, in order to host multiple servers you will want to have multiple configurations.

You can launch a server with a different configuration directory by passing in this command line option: -conf_dir 

For example, if you enter "-conf_dir MyDedi" then it will use the folder "Documents/Klei/MyDedi" for all saving, loading, and configuration that is normally stored in "Documents/Klei/DoNotStarveTogether".

===  Which save slot does the dedicated server use?'  '  === By default, 1. You can override the slot through the settings.ini option: [network] server_save_slot = 1 to 5  

Troubleshooting
In C:\Users\Mark\Documents\Klei\DoNotStarveTogether\save\ delete survival_1. When you restart a new world will be generated
 * If you ran the dedicated server before you put a token in the settings.ini you may need to delete your world data.  Shutdown the server or client,


 * If your server is running correctly, but you still can’t see it.  Confirm it’s listing here:

=
http://my.jacklul.com/dstservers/ You will have to manually update the listing at the bottom of the page ===== If it’s still not visible from inside the game client, it’s because the client can’t ping your server. Did you make sure to forward UDP traffic on port 10999 to your machine

If you get the error Account Failed (6): "E_EXPIRED_TOKEN" you’ll want to verify that you saved the settings.ini file with the server token after you closed the game client, or your change will get overwritten. Also, make sure that there are no extra characters at the end of the file, even invisible ones.