Garry's Mod

Garry's Mod

254 ratings
How to Create a Garry's Mod Server
By dhkatz
A fast as possible guide on how to create a Garry's Mod Server using SteamCMD. While many guides like to use Hamachi on here, if you can get through the hurdle of portforwarding, this is the lowest latency method!
   
Award
Favorite
Favorited
Unfavorite
Initial Setup
Creating Your Install Folder
Before you download anything, I first recommend that you already have in mind where you wish to install the necessary files for your server.

In this guide, the installation directory I will be using is "E:/GMOD/" and any references made to the installation directory will always be where you decide to make your directory.

NOTE: It is recommended that you do NOT place SteamCMD in a directory with spaces as this can cause problems. (Pointed out by ATLAS)


This is just an example of my folder location, yours may vary.

Downloading SteamCMD
SteamCMD is a terminal program created by Valve used to download and install Source Dedicated Servers, such as Garry's Mod.

SteamCMD can be downloaded here.


I will only be using the Windows version and cannot confirm if this guide will work on any other OS.

Lastly, extract the contents of the .zip file anywhere and run SteamCMD.exe (preferrably as an administrator)

Upon first launch, SteamCMD will update itself a few times. This is normal.


After updating, you will be met with a blank command line. You are ready to continue to the next section!
Installing the Dedicated Server
Connecting to the Valve Servers
Before the server is downloaded, you must connect to the Valve servers so all the server content may be requested and downloaded.

To connect to the servers, you must login. There are two ways to login: Anonymously or with your Steam account. Anonymously is usually the best and quickest, but does not always work.

To login simply type the following command:
"login anonymous"
If this method does not work you can always login with your own info:
Ex: login bobby B0bby$P@ssw0rd



Directory and Installation
Now, we are met with the longest part. Downloading the server.

First you need to tell SteamCMD where we wish to install the garrysmod server. This is the same folder you created at the beginning.

Simply enter the command:
"force_install_dir E:\GMOD"
(Note: E:\GMOD will probably be different for you)

Now to download and install the server files, enter the command:
"app_update 4020 validate"

Please note this will take some time to complete. Simply leave the terminal running.

When this is finished you will see the message "Success! App '4020' fully installed.
Starting the Server
Background Info
If you go back to your installation directory (E:\GMOD for my example) you will now see files inside of that folder. The most important file in there is srcds.exe. By itself, this file cannot do much. This is why we will create a .bat file so it can tell the .exe file what to run.

Creating the .bat File
To create a .bat file, right click in the same directory as srcds.exe and select "New > Text Document."

Text documents have the extension .txt after them, to change this, right click the text document and rename it, changing the .txt to .bat

If you cannot see the .txt extension, you have file extensions turned off in windows. Here is a quick video on how to turn them on. This video was NOT created by me.











Editing the .bat File
Open up the .bat file with Notepad or Notepad++ (I really recommend getting Notepad++ it's a great program)

This file will be blank so we must add some content to it. This code will tell the server how to start.

Go to this website and scroll to the "Extra) Restarting srcds at crash[www.srcds.com]" Section.

Copy the code inside the box and paste it into the .bat file.

IMPORTANT: The bat file comes configured for Counter Strike so you must change it to Garry's Mod. To do this change the counterstrike value after -game to garrysmod and the map from de_dust to gm_contruct.

I also recommend renaming the .bat file to start.bat

Running the Server
Simply double-click the .bat file and your server will start. Your server is finished starting when you see the message "VAC Secure Mode is activated."

At this point you should start up Garry's Mod and ensure you can connect through local network.


When connecting, check the console. It should say that you have connected:


Once you have confirmed you can connect, close your server.
Configuring the Server
Background Info
Configuring your server can be just as important as getting it to start. This section will try to be as detailed as possible to ensure you can customize your server any way you want to. Configuring the server involves the internal settings and basic admin addons that may be useful.

Locating the Server Configuration File
Inside of your server folder, the same one as srcds.exe and your start.bat, there should be a folder called garrysmod. This is where a lot of the configuration will be done inside. If you are using a file structure similar to mine. It will be located in "E:\GMOD\garrysmod\"

To get to the main configuration file, go from the garrysmod folder to cfg and open the file named server.cfg (I recommend using Notepad++ for this):
"garrysmod/cfg/server.cfg/"

This file will be initially blank and this is where you need to add your settings.

Setting Up the Configuration
There is a great website tool that will generate a server.cfg file for you to past into your own server.cfg

The website can be found here[gmod-servercfg.appspot.com].

I will not be going over all of these settings, however there are some that are very crucial to ensuring a smooth playing experience.



Important Settings:
  • Hostname: This is what your server will be called.
  • RCON Password: If you want to change settings on your server ingame, set a password so other players cannot do this.
  • sv_lan: Leave this value on 0. It means the server will be visible publicly.
  • net_maxfilesize: If you plan on having any addons, make this the maximum.
  • sv_minrate: This is crucial, if this value is too low the server will lag. I recommend setting the minimum the highest, and if it is still not enough. When you copy the settings over manually change it to a higher number.
  • sv_maxrate: This is also crucial, I recommend manually changing it to 0 after which makes the value unlimited.
  • sv_minupdaterate & sv_maxupdate rate: This is usually about what fps the server will run at. Leave them alone, but if you lag because it is too high, change max to 33.

After you have finished choosing your settings, hit "Generate" at the bottom. You do not need to download anything, simply copy over the text that was generated into your server.cfg.
Portforwarding (The Dreadful Section)
Background Info
Portforwarding is always the section where the most people have issues. It is not really a hard concept to understand, and while some people genuinely have issues, it is just a matter of knowing how to access your router.

Accessing Your Router
To access your router, you will need to know your default gateway. This is IP of your router. You can find the gateway IP for your router using Command Prompt.

Using Command Prompt
Press the "Start" button and search for "CMD." There should be a program called cmd.exe
RIGHT CLICK THIS AND RUN IT AS AN ADMINISTRATOR.

Type in the command "ipconfig"

You may see many things come up, however most likely one one will have the IP next to Default Gateway.

In my case, my default gateway is 192.168.0.1
Also copy down the IPv4 address associated with the default gateway.
My IPv4 address is 192.168.0.15



Finding the Default Gateway
Go to this website: http://portforward.com/english/routers/port_forwarding/routerindex.htm

Find your router brand, mine is Motorola, and select the game you are trying to port forward. This site will tell you the default login and gateway IP for your router.

Logging on to Your Router
On an internet browser, type in the default gateway IP that you found. You will most likely have to login. Find the login info if you do not know it on http://portforward.com/english/routers/port_forwarding/routerindex.htm


Forwarding the Required Ports
In your router home screen, try and find a section labeled "Forwarding" or "Port Forwarding" just something along those lines.



By default, the ports that all source games use are usually in the 27015-27020 range. Because of this, it is good to forward ports in that range. Note: If your router only supports single port forwarding, you can just forward 27015 and be fine.



Create a new forwarding setting, on some routers there will be no button and you just enter into boxes. That works the same way.

When creating the new forward, it will ask for a local IP. This is the same local IP that I had you copy down earlier when you found the default gateway as well.


For the sake of convenience, you can just copy my settings in the picture above (click the picture to make it bigger).

Remember to hit apply! Your router may restart.

NOTE: Some routers may require an extra step like mine. If your router has a DMZ Host setting, it is good to enter your IPv4 address there. See the picture below if you have this setting.


Checking Your Port
Now is a good time to check your port, to make sure you did everything right.

Go to the website: http://www.canyouseeme.org/

This website allows you to check if your server is visible to the open world.

Start up your server and wait for the VAC message. Then on that website, type in the port 27015 into the port box. Now click "Check Port'

If you have succesfully port forwarded, you will get the message "Success: I can see your service on YOURIPHERE on port (27015)"

If you get an error message, you did something wrong in port forwarding. Please try again.

Finding Your Public IP
Your public IP is the address that you can give your friends so they can connect to the server when it is online, of course they could also find the same of your server in the game or join on you if you join the server; but nonetheless it is a good thing to have.

Go to this website: http://www.whatsmyip.us/

That string of numbers is what you can give to your friends to connect to your server, I recommend having somebody try to connect to makesure people who are not in your home network can connect.

If your friends cannot connect you have a portforwarding issue.
[Extra] Installing ULX - Recommended
Background Info
ULX is an administration addon that many servers use to manage users and run commands through a nice interface. The addon is very easy to install and setup, so this section is recommended to do.


This is what ULX looks like with the GUI.

ULX can be downloaded from here:
http://ulyssesmod.net/downloads.php

Download the ULib 2.51 (.zip) and ULX 3.61 (.zip) (Requires ULib v2.51+) from that page

Installation
Go to your server installation folder, in this case "E:\GMOD"
Then go to the 'garrysmod > addons" folder

Open up both of the .zip files and drag the "ulib" and "ulx" folders into the "addons" folder.

That's all there is to installing.

Making Yourself a Super Admin
Start up the server and join it yourself.

Once you have joined, alt+tab out of garrysmod (leave it running).

Inside of your server console type the command "ulx adduser <name> superadmin"
Where name is your Steam name.

Since I am "The Doctor Jew" that is what I will put:

ulx adduser "The Doctor Jew" superadmin (I recommend putting quotes if your name has spaces)

Using the GUI with ULX
Great, you have installed ULX and you are now a superadmin. You may be wondering, how do I bring up the fancy GUI? Well that's easy. Just type xgui into the console!

Now, we don't want to have to type xgui into the console EVERY time we want to use the GUI right?

To avoid this you can bind a key to the command.

Take for instance the "i" key. That isn't really used in GMod, so that is the key I picked. You can use any key on the keyboard, just make sure nothing else uses it in game.

Open up the console and type: bind "i" xgui (replace "i" with any other key)
Troubleshooting & Updating
Many times people do not successfully get their server working the first try, and while I could just tell you to look to Google for help, I will at least try to go over some common issues.

SteamCMD
Most SteamCMD issues can be resolved simply by trying again. Yes, I know the download takes a while, but sometimes it is just necessary.

Friends see "Server Not Responding"
This can be a few issues.
  • This can be a few issues.
  • In your server.cfg make sure that the value sv_lan is set to 0. This means that your server is NOT a LAN server which is good.
  • Try forwarding a different port as well. In reality you can forward any port you wish, however you must add that port to the start.bat command line. For example, if 27015 does not work, try 27016 and add this to your command line.
    http://prntscr.com/55bjg2
  • Make sure your port is forwarded on BOTH UCP and TCP
  • Make sure that your local IP has not changed. Go through the command prompt steps again to check if your IPv4 address is different from what you forwarded.
  • Windows Firewall may be blocking your connection to other people.
    Open up Windows Firewall:

    Then at the top left click on inbound rules:

    Create a New Rule:

    Make it a program:

    Select the path of SRCDS.exe in your server folder.

    Allow the connection:

    Check ALL connections and name it whatever you want, like Source Multiplayer

Updating Your Server
If you want to update your server at any point (which you will have to). You only have to rerun a few commands.

Open up SteamCMD again.

Simply enter the command:
"force_install_dir E:\GMOD"
(Note: E:\GMOD will probably be different for you)

Now to download and install the server files, enter the command:
"app_update 4020 validate"

This will check all of your files and update them. If you accidently delete a file or corrupt/change one, don't worry this will redownload them.
Extra Help
In case you want a video to go along with this text guide I will be providing some helpful resources, trust me using them both together can clear up a lot of issues.

Here are two videos I believe do a good job at going through this process:



The Doc's Office

Please join the group if you need further help and ask anybody!

http://steamproxy.com/groups/doctorsguides

143 Comments
BlueSnake64 6 Nov, 2021 @ 8:30am 
░░░░░ ▄██▄░░░
░░░░░▐▀█▀▌░░░░▀█▄░░░
░░░░░▐█▄█▌░░░░░░▀█▄░░
░░░░░░▀▄▀░░░▄▄▄▄▄▀▀░░
░░░░▄▄▄██▀▀▀▀░░░░░░░
░░░█▀▄▄▄█░▀▀░░
░░░▌░▄▄▄▐▌▀▀▀░░ THIS IS BOB
▄░▐░░░▄▄░█░▀▀ ░░
▀█▌░░░▄░▀█▀░▀ ░░ COPY AND PASTE HIM,
░░░░░░░▄▄▐▌▄▄░░░ SO, HE CAN TAKE
░░░░░░░▀███▀█░▄░░ OVER ALL OF STEAM
░░░░░░▐▌▀▄▀▄▀▐▄░░
░░░░░░▐▀░░░░░░▐▌░░
░░░░░░█░░░░░░░░█░░░
egoleton 1 Apr, 2021 @ 5:53pm 
░░░░░ ▄██▄░░░
░░░░░▐▀█▀▌░░░░▀█▄░░░
░░░░░▐█▄█▌░░░░░░▀█▄░░
░░░░░░▀▄▀░░░▄▄▄▄▄▀▀░░
░░░░▄▄▄██▀▀▀▀░░░░░░░
░░░█▀▄▄▄█░▀▀░░
░░░▌░▄▄▄▐▌▀▀▀░░ THIS IS BOB
▄░▐░░░▄▄░█░▀▀ ░░
▀█▌░░░▄░▀█▀░▀ ░░ COPY AND PASTE HIM,
░░░░░░░▄▄▐▌▄▄░░░ SO, HE CAN TAKE
░░░░░░░▀███▀█░▄░░ OVER ALL OF STEAM
░░░░░░▐▌▀▄▀▄▀▐▄░░
░░░░░░▐▀░░░░░░▐▌░░
░░░░░░█░░░░░░░░█░░░
asher 11 Feb, 2021 @ 8:32am 
Night Wolf, I have an antivirus and nothing has popped up. You might have installed something else prior.
michael jackson 24 Nov, 2020 @ 1:52am 
delsestr
Gurstan Grunsst 28 Nov, 2017 @ 7:36pm 
You can Now start a Gmod server without Downloading all of this BS
petershwarz68 22 Apr, 2017 @ 2:31am 
I get a error when I start the bat file that says

"The procedure entry point SteamInternal_creatInterface could not be located in the dynamic link libray C:\Users\Murray\Desktop\GarrysModServer\garrysmod\bin\server.dll"

Thanks in advance.
Aviator 12 Aug, 2016 @ 10:53pm 
You guys can find server.cfg generator here http://gmodcfgmaker.com .
ALEX 29 Jul, 2016 @ 7:18am 
The website for the server.cfg generator is gone. Can someone plz send me the link to Another generator??
chugaze 29 Jun, 2016 @ 2:52pm 
When I do app_update 4020 validate it says ERROR: Failed to install app (no subscription)

Do I need to own anything besides GMod to do this?
Mr Mage 24 Jun, 2016 @ 8:12pm 
I'm currently having error 803
b8/10