A Garry's Mod server's server.cfg lives in garrysmod/cfg/server.cfg. The dedicated server runs it when it starts and again on every map change, so it's where your server name, passwords and other settings go.
Where the File Goes
The path starts from your server folder, the one that holds srcds:
garrysmod/cfg/server.cfgIf the file isn't there, create it as a plain text file. On Windows, turn on file extensions in File Explorer first. A file saved as server.cfg.txt won't run.
Each line is one console command or console variable, written as you'd type it into the server console. Anything after // on a line is a comment and the server ignores it.
A Starter server.cfg
Copy this, then change the values to your own:
// Name shown in the server browser
hostname "My Garry's Mod Server"
// Leave empty for a public server
sv_password ""
// Remote admin password. Make it long and never share it
rcon_password "change-this-to-something-long"
// Flag shown in the server browser
sv_location "gb"
// Server browser region. 3 is Europe
sv_region 3
// Web page shown while players join
sv_loadingurl "https://example.com/loading.html"
// Stop players running their own clientside Lua
sv_allowcslua 0
// Stop players uploading sprays
sv_allowupload 0
// Write a server log file
log onWhat Each Setting Does
| Setting | What it does |
|---|---|
hostname | The server's name in the server browser and on the loading screen |
sv_password | A password players must enter to join. Leave it empty for a public server |
rcon_password | The password for remote console access. If it's empty, RCON is off |
sv_location | The flag next to your server, as a two-letter country code such as gb or us. Use eu for the European Union |
sv_region | The region the server reports to Valve's server browser |
sv_loadingurl | A web page players see while they join. It must start with http:// or https:// |
sv_allowcslua | Set to 0 to stop players running clientside Lua with lua_run_cl and lua_openscript_cl |
sv_allowupload | Set to 0 to turn off player sprays |
log on | Turns on the server's log file |
hide_server | Set to 1 to hide the server from the server browser |
sv_location
sv_location matches a flag icon in materials/flags16/, named by ISO 3166-1 alpha-2 country code. It takes up to five characters. Facepunch's server operator rules ban faking server information, so set it to where the server really is.
sv_region
Valve's region codes:
| Value | Region |
|---|---|
0 | US East |
1 | US West |
2 | South America |
3 | Europe |
4 | Asia |
5 | Australia |
6 | Middle East |
7 | Africa |
255 | World |
sv_loadingurl
Your loading page can include the joining player's details. The server replaces %s with the player's 64-bit SteamID and %m with the current map:
sv_loadingurl "https://example.com/loading.html?steamid=%s&map=%m"The page can also define JavaScript functions that Garry's Mod calls as the player loads, such as GameDetails and SetStatusChanged. Facepunch's Loading Screen page lists all of them.
Use RCON
RCON lets you run server console commands from your own game. It uses TCP on the game port, 27015 unless you changed it with -port.
In your game's console, set the password, then put rcon before any server command:
rcon_password "change-this-to-something-long"
rcon status
rcon changelevel gm_flatgrassAnyone with the RCON password has full control of your server. Use a long random password and change it if anyone leaves your staff team. An admin mod, covered in Install DarkRP and an Admin Mod, is safer for day-to-day moderation.
Network and Rate Settings
Valve recommends keeping the default network settings. Change them only if you know why.
| Setting | What it limits |
|---|---|
sv_minrate, sv_maxrate | The bandwidth a player may ask for, in bytes per second. sv_maxrate 0 means unlimited |
sv_minupdaterate, sv_maxupdaterate | How many snapshots a second a player may ask the server for |
sv_mincmdrate, sv_maxcmdrate | How many command packets a second a player may send |
The server never sends more updates than it simulates ticks. The tick rate itself is a launch option, -tickrate, not a server.cfg setting. The default is about 66.67 ticks a second, and Facepunch recommends staying between 30 and 128.
A higher tick rate costs CPU. Valve measured a tick rate of 100 using about 1.5 times the CPU of the default 66.
Settings That Go on the Command Line
Some settings must be set before the first map loads. server.cfg runs too late for them, so put them in your start script instead:
+maxplayers 32 +gamemode darkrp +map gm_construct +sv_setsteamaccount YOUR_GSLT +host_workshop_collection 123456789sv_lan is another one. Facepunch's wiki says server.cfg sets it too late, so pass +sv_lan 0 on the command line if you need it.
autoexec.cfg
autoexec.cfg sits in the same folder, garrysmod/cfg/. The server runs it once at startup, before the first map loads. It doesn't run again on map change.
Use it for settings that only take effect after a map change. Put everything else in server.cfg, so a map change puts it back if someone changed it.
You can split a long config into several files and load them with exec. This line in server.cfg runs garrysmod/cfg/sandbox.cfg:
exec sandbox.cfgChange Settings Without a Restart
Type any setting into the server console and it changes at once:
hostname "My Garry's Mod Server | Now Open"That change lasts until the next map change, when server.cfg runs again. To keep it, edit server.cfg too.
Troubleshooting
Check the path is garrysmod/cfg/server.cfg inside your server folder. On Windows, check the name isn't server.cfg.txt. Type exec server.cfg into the server console and watch for errors.
You changed it in the console but not in server.cfg. The file runs on every map change and sets it back.
The address must start with http:// or https://, and the page must load in a browser. Open the address on your own PC to check.
Type sv_allowcslua into the server console to see its current value. If it shows 1, something set it after server.cfg ran. Search your addons and start script for it.
The password on your client must match the server's exactly. Quote it if it has spaces. If rcon_password is empty on the server, RCON is off.
Next Steps
Add addons with Workshop for Garry's Mod servers, then get listed with a GSLT and open ports.
Want to see a big DarkRP server running? Join Justified: justified.gg
