A Garry's Mod dedicated server is a Source server, so if you have ever run one it will feel familiar. The two things worth getting right are the launch line (gamemode, map and player count all live there, not in a config file) and the Workshop collection, which is what turns a bare sandbox into your server with your addons. Here is the whole setup.
Install the server
The GMod dedicated server is app 4020 and installs anonymously (no Steam login, you do not need to own the game on the server account):
./steamcmd.sh +login anonymous \
+app_update 4020 validate \
+quitThe config lives at:
<install>/garrysmod/cfg/server.cfgA vanilla server.cfg
Only identity and access go in the config; gamemode, map and player count are launch args (below). Paste this, change the values marked CHANGE ME:
// --- Identity ---
hostname "My Garry's Mod Server" // CHANGE ME
rcon_password "pick-a-long-secret" // CHANGE ME - admin console over RCON
// --- Lock it down ---
sv_password "friends-only" // CHANGE ME - join password, blank = open
// --- Vanilla behaviour ---
sv_lan 0 // 0 = public/Steam; 1 = LAN only
sv_cheats 0The launch line
GMod launches through the srcds_run wrapper at the install root. Gamemode, map and maxplayers are all arguments here:
./srcds_run -game garrysmod -console \
-port 27015 \
+exec server.cfg \
+gamemode sandbox \
+map gm_construct \
+maxplayers 16- gamemode is sandbox by default. The server only ships base, sandbox and terrortown; any other gamemode (prop hunt, murder, DarkRP…) has to be installed into garrysmod/gamemodes/ first.
- map gm_construct is the classic sandbox map. Match the map to the gamemode (a prop_hunt gamemode needs a ph_ map).
- maxplayers 16 is the GMod default; sandbox is comfortable at 8 to 16.
- Port 27015 is the game and A2S query port. Open it in your firewall (UDP + TCP).
The marquee feature: a Workshop collection
This is what people actually want: your addons auto-delivered to everyone who joins. GMod does it with a Steam Workshop collection, and it needs two things together, a collection ID and a Steam Web API key:
- Make a collection in the GMod Workshop, add your addons to it, and copy its ID from the collection page URL.
- Get a free Steam Web API key at steamcommunity.com/dev/apikey (any domain works).
Then add both to the launch line. -authkey is an engine flag so it goes near the front; +host_workshop_collection is a console command:
./srcds_run -game garrysmod -console \
-port 27015 -authkey YOUR_STEAM_WEB_API_KEY \
+exec server.cfg \
+gamemode sandbox \
+host_workshop_collection 123456789 \
+map gm_construct \
+maxplayers 16Both parts are required: the collection ID with no authkey silently downloads nothing. Clients are prompted to download the addons on connect.
The other catch: ERROR textures (mount CS:S)
Many popular maps and addons are built on Counter-Strike: Source content. Without it, players see purple-and-black ERROR textures and missing models. The fix is to mount CS:S into GMod. Install CS:S dedicated content with SteamCMD (app 232330) and point GMod at it in garrysmod/cfg/mount.cfg:
"mountcfg"
{
"cstrike" "/path/to/css/cstrike"
}That single mount clears the vast majority of missing-content complaints. TF2 and HL2 episode content mount the same way if a specific map needs them.
