Garry's Mod

Garry's Mod

825 ratings
How to host a Garry's Mod Server
By ✯Radek
A tutorial on how to host a Garry's Mod Server using SteamCMD, completely written from scratch. It will include: Installation, port forwarding, and how to add workshop addons, and a few more details.

NOTE (08. Feb 2022): This is a very old guide which I have not properly updated at least since 2017. It is possible that parts of this guide are outdated and that the process has changed in some way. If this happens to be the case, then it is highly unlikely that I will update that part to reflect the changes that have been made in GMod's update history. I stopped playing Garry's Mod years ago, so I haven't followed its updates since then either. This really shows in the poor spelling and wording at some places that probably hasn't changed since I wrote this guide back in 2013, when my English skills were still leaving a lot to be desired.
Download and use SteamCMD
First, you need to download SteamCMD, of course. This program is used to install the actual files for your server, and to install the Garry's Mod files.

You can download SteamCMD here.
(Direct download link http ://media.steampowered(.)com/installer/

It is a .zip file. Extract the steamcmd.exe file inside it (extract into its own folder because the files will be installed into the directory of steamcmd.exe), and then run it.


Now, that SteamCMD is ready, we will begin installing the server.

First, you start off by logging in. Type this command in the command prompt that is currently open:

login anonymous

The command prompt should return this information:

After logging in, you have to determine the path where the server will be installed.
To do this, use this command:

force_install_dir <path>

To avoid any issues regarding the directory, just set it directly to your C:\ drive, or to some other external drive.
force_install_dir C:\gmodserver

If you want to set the path to something further than just the C:\ drive, then type out the path carefully, and make sure it contains no spaces, otherwise it will make seperate folders.

To install the Garry's Mod files, type the following command in the prompt:

app_update 4020 validate
If you have quite slow internet, then this process could take about half an hour. Fast internet however can do this quickly in just a few minutes.

4020 is the ID of "Garry's Mod Dedicated Server", not to be confused with 4000, which is the AppID of the game Garry's Mod itself.

To add other game content to your server(e.g:TF2, DoD:S etc.), you have to use the app_update command again. You just have to change the ID 4020 to the ID of the game you want to mount, and change the force_install_dir as well (I recommend making a folder inside the server folder which you install it into). However, it is very likely that these install possibilities do not allow anonymous login. In this case, you have to login with your steam username and password.
Automating the Process
Mostly copied from the valve developer wiki, only because it's fairly useful material.
Only useful for updating your server.
You can also automate this process. There are 2 ways to do that:

NOTE: steamcmd = ./ on Linux

Way 1

Run the commands all at once:

steamcmd.exe +login anonymous +force_install_dir <path> +app_update 4020 validate +quit

If you are logging in with an account, use username password instead of "anonymous" at the +login command.

Way 2

Make a script:

// gmod_server_update.txt // @ShutdownOnFailedCommand 1 //If updating multiple servers at once, then set this to 0. @NoPromptForPassword 1 login anonymous/username password // Use either "anonymous" or login with an account. force_install_dir path app_update 4020 validate quit

Then run this script with the +runscript command in SteamCMD:

steamcmd +runscript gmod_server_update.txt
Configuration of your server
Our server is now installed. Now, we have to configure it, to make it work properly and to keep things organized.
First thing you should do, is to configure the server.cfg file. This file is used to set the Sandbox limits, and to set all console commands that are getting automatically executed when the server is booting up.

This file is located here: drive name:/Program Files(x86)/yourfilepath/blah/steamcmd/garrysmod/cfg

An example of a server.cfg file would look like this:
//The lines are used to make big spaces, since using blank spaces does not work in Steam. Replace the lines with blank spaces, or press "TAB" around 6 times to make a big space.
"hostname"--------------------------------------------"My Garry's Mod Sandbox Server"
"sbox_noclip"-----------------------------------------"1" //Enables noclip
"sbox_playershurtplayers"-------------------------"1" //Enables PVP Damage
//And you can put in some different console commands which you want to be "autoexecuted"
Note that this is just an example to show you how a proper config file looks like syntactically.

Formated in a table:

my Garry's Mod Sandbox Server
Determines the server name
Sets the RCON password
Sets the server password
Enables/Disables noclip
Sets the prop limit
Sets the maximum effect amount
Sets the maximum emitter amount
Sets the maximum Thruster amount
Sets the maximum SENT amount
An unconfigured server.cfg file only contains 3 blank lines.

For better security, I recommend to put the RCON password into the parameter line of your srcds.exe shortcut with +rcon_password password. However, you can also completely disable RCON by simply not setting a password.

To run your server, you must exit the "garrysmod" folder and make a shortcut of the srcds.exe file.
Then, right click on the srcds.exe shortcut, click on "Properties", and enter this command line in the parameter line:

-console -game garrysmod +map gm_construct +maxplayers 4
The "Parameter Line" is the line where the path of the executable is in; the "Target" line. Unedited, it looks like this:
C:\folder name\srcds.exe
Example: C:\gmodserver\srcds.exe

After the directory, you can enter as many other commands as you like. They all get executed as the server is launched. Commands that start with a dash (-) are game engine startup parameters, while commands that are initiated with a plus (+) are console commands.

And then add the commands after it.

Double-click the shortcut, and the server should start up.
Forwarding Your Port
Simply doing these steps is not enough. The server seems to run, and you are able to join, but the server is not yet publicly visible. When somebody outside of your local area network tries to join your server, they will get the "failed after 4 retries" message.

This is because nobody but you, at the moment, has the permission to connect to your host. This is where port forwarding comes in. Port forwarding will not make your router settings accessible from anywhere, all it does is open up a port to be publicly accessible from the internet when somebody tries to establish a connection with your IP address. This is required because routers block any external incoming connection attempts by default, for security reasons. This is why you have to step in and configure your router to allow incoming connections on a specific port. In the case of Garry's Mod, it is ports 27015 onwards, because that's what the Source engine uses.

What you have to do in steps:

1. Go to your desktop and open up your start menu.

2. Search for "cmd" in the search bar, and open the command prompt.

3. In the command prompt, type "ipconfig" and press ENTER.

4. A list of IPs and other miscellaneous information should appear. Search the "Ethernet Adapter LAN" section. If your computer is connected to your router through Wi-Fi, then you will likely not have this section. In this case, you have to find the appropriate section that corresponds to your connection type.

5. When you found your appropriate section, look up the Standard Gateway, and remember it. You may have two entries, one that is an IPv4 address (, and one that is an IPv6 address (ffff:ffff:ffff:ffff ...). In that case, always pick the IPv4 address.

6. Open up your web browser, type in the default gateway into the URL bar, and press enter. With this, you should be able to access the configuration panel of your router. A login screen should appear, either the stock login popup of your browser, or a website login page.

7. Enter the login information for your router. What the login information is depends entirely on the router you use, and whether somebody else in your household has already changed it. If you don't know the information, ask anyone who might know it, or look it up on your router box. Often though, both the username and the password are just "admin" when factory settings are left unchanged.

8. Set up the port forward. For this, find a section for forwarding ports (it's different on all router pages), and fill in all required values and information. You can set the Service Port as 27015-27016 (Use 27015 only if only one port is required), the IP Address your IPv4 Address, and the Protocol "Any" or "All" or "TCP/UDP" (Again, depending on your router page). If you do not have such an option, then you can try to create two port forwarding entries with the same data, except one with TCP and the other with UDP.

9. Save your configuration, and then enable it, and you should be done.
Setting up a Static IP Address
This part is outdated, as it shows the process for Windows 7, which is no longer being supported. In Windows 10, you can try to simulate this part with the classic control panel by hitting Windows Key + R and then typing in "control", but without any guarantees that this will work.

This step is entirely optional, it is not crucial for making anything work about your server. Setting up a static IP address is explained below.

Open up your command prompt, and run the command "ipconfig /all" without the quotes. Then, look up the IPv4 Address, the Subnet Mask, and the Default Gateway. We will use this information later.

Next, open your start menu, and click on "Control Panel". Then, search the "Network and Internet" entry, and click on the button which should say something like "Show Network status".

You should enter a window that shows your Networks, and "<Your PC Username> -> More Networks -> Internet".
Look at the upper left corner of the window, and click on "Change Adapter Settings".

After this, right click on "LAN-Connection", and then click on "Properties".
You should see a list of which elements your connection uses. Double-click "Internet Protocol Version 4", and you should enter the IP Settings of it. After you have done this all, tick "Use the following IP-Address". Doing this should automatically tick "Use the following DNS-Server Address:"
The IP-Address you insert is the static one. It should be very similiar to your actual IP address. Let's say, your actual IP address is In the box, you type in
The Subnet Mask is the one you got from your ipconfig. Same with the Default Gateway.
Now, you have to fill out the DNS Server address fields. To keep it simple, you can just use and, which is the DNS server of Cloudflare. Alternatively, and would be Google's DNS server. There is a chance that your ISP already directs you to one of those servers.
Workshop Addons for your Server
To make it simple and clear, I listed up the steps you have to do to add workshop addons for your server:

1. Create a steam collection with all addons you want to use on your server
2. Get the ID of the collection. It's the long number at the end of the collection's page URL, /id=123456789(Right Click on collection page -> Copy Page URL).
3. Use the ID to link the collection with your server. For this, you have to add the following parameter to the srcds.exe shortcut:

+host_workshop_collection <Collection ID>

An authkey is required to make +host_workshop_collection work. You can get one here.
You can use anything as the domain name.

You need to add the authkey to the parameter line as well. To do this, use this parameter:

-authkey <your authkey>

But wait, there's more!

The addons might be on your server now, but all addons that have their own content will show error signs and checkerboard textures as well as missing sounds, if the player doesn't have the addon installed on their client. So we need to force a download of their content, in a way which will be explained below.

Go to your server's lua/autorun/server directory, and create a .lua file, with any name you prefer.
Here, we will need the function resource.AddWorkshop.
resource.AddWorkshop( "id" )
You need to retrieve the ID of all the addons you want the content to be downloaded of. This is done the same way as with your collection: Go to the addon's workshop page, and copy the number at the end of the page URL.
Once you got the ID of all the addons you need, insert a resource.AddWorkshop line for every addon that has custom content, with "id" being replaced with the workshop ID. The ID has to be wrapped in quotes, as the function takes a string as a parameter.

resource.AddWorkshop( "123456789" )
Common and useful console commands for managing your server
This is a list of the most commonly used and useful console commands which can be used to manage and configure your server to your likings.

-gamemode <gamemode folder name> - Change the gamemode quickly (it will reset back to the gamemode set in the server.cfg file after the server reboots!)
-gamemode_reload_cl - Reloads the gamemode on the client
-banid - Add a user ID to the ban list (default way of banning people, use an admin mod for banning)
-banip - Add an IP address to the ban list (use admin mod for banning)
-sv_cheats 0/1 - Allow cheats on the server
-sv_gravity <value in number> - Set the world gravity. Default is 600
-sv_noclipspeed - Set the noclip speed. Default is 5
-sv_password - Set the server password
-sv_shutdown - Shuts the server down if it's empty
-sv_kickerrornum - Sets the lua error limit before a player gets kicked for them. (recommended 0)
-ai_ignoreplayers 0/1 - Toggles the "Ignore Players" setting
-ai_keepragdolls 0/1 - Toggles the "Keep Corpses" setting
-ai_disabled 0/1 - Toggles the "Disable Thinking" setting
-sbox_godmode 0/1 - Toggles godmode for all players generally (people will only be able to die by map events/triggers)
-sbox_maxballoons - Maximum balloons
-sbox_maxbuttons - Maximum buttons
-sbox_maxdynamite - Maximum dynamite
-sbox_maxeffects - Maximum effect props
-sbox_maxemitters - Maximum emitters
-sbox_maxhoverballs - Maximum hoverballs
-sbox_maxlamps - Maximum lamps
-sbox_maxlights - Maximum lights
-sbox_maxnpcs - Maximum NPCs
-sbox_maxprops - Maximum props
-sbox_maxragdolls - Maximum ragdolls
-sbox_maxsents - Maximum scripted entities
-sbox_maxspawners - Maximum spawners
-sbox_maxthrusters - Maximum thrusters
-sbox_maxturrets - Maximum thrusters
-sbox_maxvehicles - Maximum vehicles
-sbox_maxwheels - Maximum wheels
-sbox_noclip - Allow/Disallow noclip
-sbox_playershurtplayers - Toggle PVP damage
-sbox_weapons - Toggle spawn with weapons

Feel free to suggest any more console commands for this list.
Final Note
That was all (or well, most) stuff I know about hosting a Garry's Mod Server. If something went wrong during installing the server, then you can ask in the comments, and I, or someone else, can maybe help you solve the problem.

Please do not add me for questions, post your problem in the comments, so people with the same or a similiar problem can look up the solution if one is found. This guide is starting to age pretty terribly, and I can't continue being the customer support forever.
Italic = Question
Bold = Answer

What is the Parameter Line?
The Parameter Line is the "Target" line you have to type the parameters in. In total, it is the directory that gets executed when you access the srcds.exe shortcut you created earlier, along with all the game engine parameters and console commands that you entered.

How to change the gamemode (to DarkRP)?
You can try this: Insert "gamemode"-----------"darkrp" in your server.cfg file with Notepad++(Replace the dashes with tab indentations) if you have the DarkRP gamemode in your "gamemodes" folder of the server's garrysmod files. Or add +gamemode <folder name> to the parameter line. You can find out the folder name by opening the .gma file of it with SharpGMad.

That isn't even a question, but well. If it doesn't work, then point out WHAT doesn't work, and I, or maybe someone can help you.

When I run app_update 4020 validate, it says "no subscription" and refuses to install the app. How do I fix that?
You have to log in anonymously by running the command "login anonymous" to make it work. You seem to have forgot to do this.

When I try to install the app, I get error "Error! App '4020' is <number>x<number> after update job." What does that mean?
That means, that the directory you determined with force_install_dir seems to be invalid. It may not be your client GMod directory, use a completely different one, and make sure it contains no spaces (this shouldn't actually cause this error, but just to be safe, do not put any spaces into your directory). I recommend to use a completely new directory just for your server, to keep everything clean.

I get this error: [ERROR] lua/autorun/addons.lua:1: attempt to call field 'AddWorkshop' (a nil val
ue) when I make my lua file for downloading workshop content. What can I do about that?

Make sure the lua file is located in lua/autorun/server of your server files, and that you use "resource.AddWorkshop( "id" )" for marking all the workshop addons you want to be downloaded by the players.

My server is running, and I forwarded the port, but my friends still cannot join!
Either your port forward configuration is faulty somehow, or your firewall is blocking your network from performing whatever necessary operation. So in this case, you can either try temporarily disabling your firewall, or investigate precisely what you did wrong in your port forwarding settings.

The server.cfg file is empty when I open it. Is there anything wrong?
There is nothing wrong if it's empty. When it's not edited, it only contains 3 blank lines. If it doesn't, then that's not a problem either.

How do I make myself an admin on my server?
It is strongly recommended to use an admin mod for that, as it is much easier to handle this kind of stuff with one. If you want to go the simple, "standard" way, go to (your server's folder name)\garrysmod\settings\users.txt and add yourself as a superadmin there. (Open the file with notepad++ or similiar, as the file looks messy in stock Notepad.)
< >
Cirno Dec 21, 2023 @ 3:16pm 
You could try hosting the server through IPV6, but I have no idea if it supports being hosted or connected through IPV6, but that is the way it has to be from now on, since we absolutely ran out of IPV4 address.
Majority of games and apps doesn't supports IPV6, if G'mod si the same case, hopefully somebody can make a mod for it.
Michael2911 Dec 19, 2023 @ 4:55am 
Because the public IP is within CG-NET, the ports do not open as they should and I have no choice but to call the internet provider to fix this problem with the ports.
Soerix Sep 21, 2023 @ 12:58pm 
No one can join my server execpt me, i did all right, i think, i added my Ethernet IP and set it up right with IP, Subnet prefix Length, And DNS wich were all included in my cmd Ipconfig, i Port forwarded by adding my description named server, Used ALL Because there was no TCP/UDP Option only TCP and UDP by themselves, and used the ports you said to use and even placed one in my start.bat, no one can join still execpt just me
filthy avian creature Apr 3, 2022 @ 1:18pm 
Backing up the comment below. This guide saved me hours of effort and research into SteamCMD. Big vouch for キャルビンシュン below, as well! That tool is incredibly helpful. No need to open every single workshop item and copy the ID-- that script is incredibly simple to use, and saves a ton of time.
The Bunkerman Apr 3, 2022 @ 11:31am 
Regarding this guide being potentially out of date, I can confirm that nearly all of it is still applicable, and all the important bits are still fine. *However*, SteamCMD now requires that you specify force_install_dir before you login anonymously, so that's the only thing that would need to be changed.

Great guide by the way! I do Source servers day in and out and still come back to this guide as a refresher once in a while.
Cirno Nov 30, 2021 @ 5:03pm 
@787878 takeover 1984 hina your ports could also be blocked by your ISP.
Thou, if you have more than 1 router you need to open in them all, including the modem if it has a configuration window.
Слесарь-Токарь Nov 30, 2021 @ 4:19pm 
My port forward does not open ports.
キャルビンシュン Nov 19, 2021 @ 5:20pm 
@a flied fly - you will need to add each item individually. If you want something to help with this process, I have a github repo [] that has what I wrote a few years back and have maintained in order to make my own servers easier to do this with (albeit still not automatically done due to how infrequent these collections are updated).
filthy avian creature Nov 3, 2021 @ 9:58pm 
Probably won't get an answer tonight when I need it, but is it required to put every single workshop addon ID for resource.AddWorkshop ( "id" ), or can you just do the collection?
Razer Cortex Oct 20, 2021 @ 6:41pm 
To be honest this is way easier than publishing a addon. Which I would know because I have uploaded a map before.