Steam Users' Forums Left4Dead2 Dedicated Server Setup Guide
 Register FAQ Search Today's Posts Mark Forums Read

07-27-2010, 07:00 AM   #1
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241

Left4Dead 2 Dedicated Server Setup Guide for Windows

Modified date: August 2, 2013
Added/Changed: Added a note about NAT Loopback in the second post below. Added instructions for using SteamCMD and removed defunct instructions for HLDSupdatetool.

I reformatted this guide again in an attempt to help people understand how to get your own dedicated server running. If you have suggestions on either layout, additional settings to add or remove or if you see errors, please let me know and I'll fix it. Please help to improve this guide so it is usable and understandable to as many people as possible. This guide is by no means a complete list of settings you can use in you server setup. It is meant to help people, (newbies trying to set up a dedicated server), set up a basic server and to help others understand how to connect to the server.

For this guide we'll be using the console version of the dedicated server. Download the Windows SteamCMD program here.

Installation
Now the first thing you want to do is extract this program to a directory like C:\SteamCMD
After you have done this, open a command prompt. (Click start and navigate to Accessories. Launch the command prompt from there.) Once it is open, type
Quote:
 cd\SteamCMD
and press enter. What this will do is put you into the directory you extracted the SteamCMD program. Now for the command to start things off.

In the command prompt, type
Quote:
 steamcmd
then press enter. The program will update itself then give you a Steam> prompt.

At the Steam> prompt, type
Quote:
At the moment, most games require you to login anonymously.
If that does not work, you would have to use your Steam account credentials. First, make sure you are not already logged into steam.
Second, type
Quote:
Check your email for the Steam Guard code and enter it. You should see and confirmation that you have successfully logged into your account.

At the Steam> prompt, type
Quote:
 force_install_dir
Example: force_install_dir c:\L4D2DS

This doesn't install anything at this point however. It just tells SteamCMD where you want to install.
Start the install process. (You can find Steam Application IDs here.
The id for L4D2 is 222860
Type
Quote:
 app_update 222860 validate
This will start installing L4D2 Dedicated Server and validate the files.

(You can automate SteamCMD with a batch file and save you typing if you prefer. Just save the line below as a .bat file and put it into the C:\SteamCMD directory. Create a shortcut to it and place on your desktop. Edit the line to use your install directory.)
Quote:
 steamcmd +login anonymous +force_install_dir c:\L4D2DS +app_update 222860 validate +quit
Run this file again any time you need to update your server.

NOTE:
Configuring your server is much as it was using HLDSupdatetool however, the server does not seem to work with the current stable release of SourceMod. The server will launch then shut down immediately. For my server I used the latest Development branch of SourceMod 1.6 and it works so far but more testing is needed. The 1.5 branch may work but I haven't tested it yet.

Configuration
After it has finished downloading you will need to make yourself a simple text file to configure the server. Create a text file and name it server.cfg
In this file you are going to add a list of commands to allow your server to run. Below is a basic config that will get you up and going.
Quote:
 hostname "servername" rcon_password "password" sv_search_key yourkey //sv_password "password" // Password protects server sv_allow_lobby_connect_only 0 hostfile "my_host.txt" //create custom hostfile else the //file will be overwritten after every update mp_disable_autokick 1 sv_alltalk 0 sv_consistency 1 //sv_contact "address@gmail.com" sv_voiceenable 1 sv_region 255 //sets region to all areas sv_log_onefile 0 sv_logbans 1 sv_lan 0 sv_pure "1" sv_cheats "0" //sv_gametypes "coop,versus,survival,scavenge" //sets gametypes //sv_unlag 1 //sv_maxunlag .5 //setmaster add 68.142.72.250:27011 //setmaster add 72.165.61.189:27011 sv_steamgroup "01234" //this is your group's steam group id. This option works with or without the quotes. //sv_steamgroup_exclusive 1 //to make it exclusive and private
The lines that have // at the beginning of the line tells the server to ignore those lines. You would have to remove the // in order for the server to read those lines. In this case they are commented out because they aren't really needed for you to get your server up and running. Change servername in the hostname line to whatever you want to call your server. Change password in the rcon_password line to a password of your choosing that you want to keep for server administrators only. Once you have created your server.cfg file you want to save it to your cfg directory.
Quote:
Create a shortcut
The next step you need to take is to create a shortcut to your server executable. Open your install directory. (C:\L4D2\left4dead2) Locate the file scrds.exe Create a shortcut from this. Move the shortcut to your desktop if you prefer.
Using your mouse, right click on the shortcut and select properties. In the target line you are going to add some commands there as well. Change the target line to look like this:
Quote:
Using sv_search
To use the sv_search_key option, you can add a line sv_search_key yourkey in your autoexec.cfg file for the client computer where "yourkey" is changed to whatever you made it in the server.cfg file. You can create your autoexec.cfg file and place it in your cfg folder, normally located in
Quote:
Rather than adding your sv_search_key to your autoexec file, you can use a method I use. I'll list that below.

Creating a lobby
Now this part seems to cause some confusion for some. Me included until a person on these forums helped me understand it. Launch your server. Now onto the client computer. Launch the game.

Choose a game mode you would like to play. For this case we'll say versus. Click on the versus icon. Select the Play With Friends option. On the next window, click Create Versus Lobby. In the next screen, select a campaign you want. Then for Server Type select Best Available Dedicated then click Create Lobby. After you click that the lobby will be created. At this point you will need to enter one of the commands to make your lobby connect to your dedicated server.

Next, you need to type a command into the console. This part is important if you are playing on your own lan.

In the game, hit the ~ key to open the console. If the console doesn't open that way, you need to enable it. Follow the instructions below.
Quote:
 In the game, click Options Click Keyboard/Mouse Click Allow Developer Console Select Enabled
In the console, type
Quote:
 mm_dedicated_force_servers xxx.xxx.xxx.xxx
and hit enter.
Note: replace xxx.xxx.xxx.xxx with your WAN address. You can go to a website like http://www.whatismyip.com/ to get your address. Click the invite friends button and wait for them to connect. Once they connect you're good to go.

Or you can use the sv_search_key method as listed below instead of using mm_dedicated_force_servers.
Quote:
 sv_search_key yourkey
Just change the "yourkey" part to whatever you used in your server.cfg for the sv_search_key line.

Personally, I have both commands bound to a function key so I can avoid typing that each time I create a lobby. If you prefer to bind those commands to a function key yourself, the command to do so is below. Open your console and type the following commands. You can change the F3 and F4 keys to any key of your choice. Do make note however, F1 and F2 are used for voting so don't change those. F12 I believe is set as default for screenshots.
Quote:
 Bind F3 "sv_search_key yourkey"
Quote:
 Bind F4 "mm_dedicated_force_servers xxx.xxx.xxx.xxx"
After you entered those commands, simply press F3 while in your lobby to make the lobby connect to your server once you select to start. You may find the sv_search_key does not always work 100%. In that case, simply hit F4 for your mm_dedicated_force_servers command then click to start again.

Port Forwarding
Port forwarding is not usually needed if you have a direct connection to the internet.
Look for your router model in the list. Once you find it, click on the corresponding link.
Look through the list of games for "Left 4 Dead 2" and click that link. Follow the instructions there to open the proper ports for your router.

Server crash relaunch
To make the batch file to relaunch your server if for some reason it crashes.
Quote:
 @echo off cls echo Protecting srcds from crashes... echo If you want to close srcds and this script, close the srcds window and type Y depending on your language followed by Enter. title srcds.com Watchdog :srcds echo (%time%) srcds started. start /wait srcds.exe -console -game left4dead2 -maxplayers 8 +sv_lan 0 +map c5m1_waterfront echo (%time%) WARNING: srcds closed or crashed, restarting. goto srcds
Save the file in C:\L4D2\left4dead2\ (the same location as srcds.exe) and name it something like L4D2Server.bat when finished. Double Click L4D2Server.bat to start server with crash protection. (You can make a shortcut off of this file and place it on your desktop to make it easier to find and launch.)

Additional server configuration options (with descriptions.)
Quote:
PLEASE NOTE: This is by no means a complete list. There are many more commands that can be put into the server config.

SourceMod and Metamod:Source
These are addons for your server that allow many more changes than you can do in the configs alone.

SourceMod
http://www.sourcemod.net/ - SourceMod main page.
http://www.sourcemod.net/plugins.php - You can find a large list of plugins to play with here.
http://wiki.alliedmods.net/index.php..._Documentation - Go here for installation instructions.

Metamod:Source
http://www.metamodsource.net/ - Metamod:Source main page.
http://wiki.alliedmods.net/Category:..._Documentation - Go here for installation instructions.

Some plugins you may find interesting.

[L4D2] Survivor AI Trigger fix
This does NOTHING if there is at least one human on the Survivor Team. Otherwise it triggers Crescendos, Finales and warps Bots ahead at pre-programmed stuck spots.

[L4D/L4D2] Infected Bots (1.9.8) (Versus Coop/Coop Versus)
- Allows Infected bots to be spawned in versus
- Play as the infected in coop/survival
- Play against survivor bot AI in versus (great practice for single player)
- Various cvars for maximum customization including more than 4 infected players
- Auto kicks idle infected bots
- And much more!

[L4D2]Tank Rush
Get rid of the CI and all other SI and have a race to the saferoom with just tanks chasing you.
See it in action.

[L4D2] Jockey racing v1.0.8(+ 4 player mode)
This plugin allows players to race in teams of 2 with jockeys to the safehouse.
See it in action.
There is an alternate video that shows more of the abilities of the plugin. Check it out here.

[L4D2] Incapped Crawling with Animation (1.03)
Enables survivor crawling and adds the crawling animation to incapped players. The animation is already in the game so no extra files needed.
See it in action.

[L4D & L4D2] Game Mode Config Loader 1.6
This plugin will execute a config file based on the current game play mode.

09-22-2010, 09:26 AM   #2
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Installing SourceMod and Metamod
After you unzip SourceMod you'll end up with 2 folders. addons and cfg. Open your
Quote:
folder. Copy the addons and cfg folder there. Windows will likely pop up a dialog saying The destination already contains a folder named 'addons'. Click ok or yes to copy the files over. You'll get the same popup for the cfg folder.

Installing Metamod is a little more involved but not much. After you unzip Metamod you'll be left with 1 folder. addons. If it's not still open, open your
Quote:
folder and do the same as you did with the SourceMod addons folder.

Next you'll make a vdf file. Go to http://www.metamodsource.net/vdf and in the Game box select Left 4 Dead 2 in the dropdown list. Leave the next box alone. Click the Generate metamod.vdf button. Save that file and copy it to your
Quote:
folder.

To install your plugins for SourceMod, copy the *****.smx file into
Quote:
After you have installed SourceMod, Metamod and your plugins, you'll want to make some edits to files for SourceMod for things like, Admins, adding groups, reserved slots.
Go to http://wiki.alliedmods.net/index.php..._Documentation and follow the documentation there to edit the cfg files for SourceMod.

Mutations
Mutation mode in game
Playing mutations when they are not in rotation is relatively easy since the needed files for each mutation are already in your game files. There are multiple methods to play a mutation. If you just want to play a mutation mode within your game, the steps are as follows;

First, decide on a campaign you want.
Quote:
 c1m1_hotel = Dead Center c2m1_highway = Dark Carnival c3m1_plankcountry = Swamp Fever c4m1_milltown_a = Hard Rain c5m1_waterfront = The Parish c6m1_riverbank = The Passing c7m1_docks = The Sacrifice c8m1_apartment = No Mercy c9m1_alleys = Crash Course c10m1_caves = Death Toll c11m1_greenhouse = Dead Air c12m1_hilltop = Blood Harvest c13m1_alpinecreek = Cold Stream
Then decide what mutation you want to play.
Quote:
 mutation1 = Last Man on Earth - One player vs Special Infected mutation2 = Headshot! - Common Infected only killed by headshots mutation3 = Bleed Out - Slowly lose health continuously mutation4 = Hard Eight - 8 Special infected instead of 4 mutation5 = Four Swordsmen - Only Katanas mutation6 = Unused at the moment. mutation7 = Chainsaw Massacre - Only chainsaws mutation8 = Iron man - No ammo. No respawns. mutation9 = Last Gnome On Earth - Each team must carry a gnome mutation10 = Room For One - Only one survivor allowed in escape vehicle mutation11 = Healthpackalypse - No health throughout the levels mutation12 = Realism Versus mutation13 = Follow the Litre mutation14 = Gibfest - M60 Unlimited ammo mutation15 = Versus Survival mutation16 = Hunting Party mutation17 = Lone Gunman mutation18 = Bleed Out Versus mutation19 = Taaannnk!! mutation20 = Healing Gnome community1 = Special Delivery community2 = Flu Season community3 = Riding My Survivor community4 = Nightmare community5 = Death's Door community6 = Confogl
After deciding the map and mutation, you just need to enter the command in the console to play.
Say you want to play Dark Carnival on the Bleed Out mutation. Open your console and type,
Quote:
 map c2m1_highway mutation3
Hit enter after typing this line. The game will load Dark Carnival on the Bleed Out mutation. Once you are in the game and decide you don't want to play that campaign, call a vote and change the campaign. It should stay on the mutation you selected. You can also call a vote to change the difficulty. I have read that you can also call a vote to return to lobby but in my case, that option is grayed out but may not be for everyone.

Mutation mode in dedicated server
Playing a mutation mode on a dedicated server is a little bit different but still simple to do. You would have already made a shortcut to launch the server with some options in the target line. Simply add,
Quote:
 +mp_gamemode "mutationxx"
So your shortcut in the target line might look similar to this,
Quote:
 C:\L4D2\left4dead2\srcds.exe -console -game left4dead2 -maxplayers 8 +sv_lan 0 +map c5m1_waterfront +mp_gamemode "mutation3"
There are other ways to start a mutation on a dedicated server but the simplest is to use a mod such as Rayman1103's Mutation Mod. You can find that, here.

If you don't have access to modify the shortcut, you can do it another way but it is slightly more involved. For this method you will need rcon access to your dedicated server. Create a lobby and start it. Don't wait for anyone else to connect to the lobby. You'll see why shortly. Once you are into the game, open the console and enable your rcon access.
Quote:
Next type,
Quote:
 rcon map c2m1_highway mutation3
to force the server to load Dark Carnival on the Bleed Out mutation. Once you hit enter, the server will likely boot you and anyone else that might have connected. Wait a few seconds, to give the server time to finish loading the mutation and reconnect but, either connect by typing
Quote:
 connect xxx.xxx.xxx.xxx
in the console or connect through steam group servers. Don't forget to change xxx.xxx.xxx.xxx to your server address. Again, once you reconnect, you can call a vote to change campaigns or you can change difficulty. It's possible you might see the option for calling a vote to return to lobby. In my case, I don't get that option. From what I read, if you can call a vote to return to lobby, it will place you in the lobby of that mutation mode you set. It's possible the return to lobby was grayed out for me because I was the only human playing at the time. It may need more than one human player in order for the vote to return to lobby option to work.

Below is a quote from ajs410.

When it comes time to do updates, I have a batch file command that I use. It saves a copy of the output from hldsupdatetool to a file named after the date and time. This is nice so that way I can see what files are being changed.

Code:
hldsupdatetool -command update -game left4dead2 -dir C:\L4D2 > C:\L4D2\L4D2Update__%date:~10,4%_%date:~4,2%_%date:~7,2%__%time:~0,2%_%time:~3,2%_%time:~6,2%.txt
Unfortunately, this prevents you from seeing the output yourself. You have two options for fixing that:

Code:
set dd = %date% %Time%

hldsupdatetool -command update -game left4dead2 -dir C:\L4D2 > L4D2Update__%dd:~0,2%_%dd:~3,2%_%dd:~6,4%___%dd:~11,2%_%dd:~14,2%.txt && type L4D2Update__%dd:~0,2%_%dd:~3,2%_%dd:~6,4%___%dd:~11,2%_%dd:~14,2%.txt
This will show the output, but only after the hldsupdatetool has finished running.

If you want to see the output while it's being written to the file, you'll need to get gnuwin32 so you have a win32 port of the unix tee command. http://sourceforge.net/projects/getgnuwin32/files/

The instructions aren't very straightforward, make sure you read the readme.txt. But once you have that, you can see the output as it's written to the file.

Code:
hldsupdatetool -command update -game left4dead2 -dir C:\L4D2 | tee C:\L4D2\L4D2Update__%date:~10,4%_%date:~4,2%_%date:~7,2%__%time:~0,2%_%time:~3,2%_%time:~6,2%.txt
_________________________________________________

Note on NAT Loopback:
I thought I should add some info for people running into this issue and not being able to track down the cause. Your router MUST support Nat Loopback. I believe this is necessary for all SRCDS servers. If your router does not support Nat Loopback, people will not be able to connect to your server at the same time you do depending on the IP you use in the lobby. If you use your WAN IP, you will time out but others should connect. If you use your LAN IP, you should connect but others will time out. To my knowledge, there is no workaround for this issue other than having a friend host your lobby using your WAN IP or replacing the router. Most modern routers support NAT Loopback.

_________________________________________________

Credits
GivinPain - He gave me a tremendous amount of help getting set up in the first place and also for helping me to test my server.
Ninefingers - He inadvertently taught me a few things about the lobby. Surprise Nine. :P
Drowning Witch - Gave me some help with the mutations on dedicated servers.
AtomicStryker for the Survivor AI Trigger fix plugin
mi123645 for the infected bots plugin.
Fleepster99 for the Jockey racing plugin.
Silvers for the Incapped crawling plugin.
Thraka for the Game Mode Config Loader plugin.
ajs410 for the additional batch updating information.
SteamCMD - Valve Developer Community

Thank you very much guys and girls and anyone else that helped but I forgot to mention.

Last edited by crash2004: 08-22-2013 at 07:50 AM. Reason: Note about NAT Loopback

 09-22-2010, 01:16 PM #3 Method320      Join Date: Aug 2007 Reputation: 236 Posts: 729 Dont forget to mention the part where EVERY SINGLE PERSON that starts losing will say either "You pay for a server lol", or "♥♥♥♥in modified server" regardless of whether or not your server is modified.
 09-22-2010, 02:37 PM #4 Abaddown   Guest Posts: n/a Very detailed post. Nice job putting it together.
09-22-2010, 03:32 PM   #5
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Quote:
 Originally Posted by Method320 Dont forget to mention the part where EVERY SINGLE PERSON that starts losing will say either "You pay for a server lol", or "♥♥♥♥in modified server" regardless of whether or not your server is modified.
Oh yeah, that too. lol. Some people don't like modified servers for sure but a lot do. Do you guys think I should add a line about some people not liking mods? Like a warning or something like that.

09-22-2010, 03:36 PM   #6
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Quote:
 Originally Posted by Abaddown Very detailed post. Nice job putting it together.
Thanks.

 09-28-2010, 11:20 AM #7 ryancee7   Join Date: Jun 2010 Reputation: 135 Posts: 1,256 Hey I got my server working I can join it now. All I had to do was put '-secure' in the launch options. Wow that simple... took forever. Most people get a ping of 120 and they complain it's terrible. For me a Ping of 120 is luxury... I got many friends test it and they say it runs great, only a little bit of stutter during mega mobs, but nothing to bother you, yet you always get 1 complainer thats like "Latency is terrible!" Oh go play official with your great 40 ping... Anyway I've edited a lot of Cvars, made a tougher witch, actually made a worthy tank by upping his health, editing his fist radius, making him faster than survivor, etc. I'm going to have fun with this :P
09-28-2010, 11:28 AM   #8
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Quote:
 Originally Posted by ryancee7 Hey I got my server working I can join it now. All I had to do was put '-secure' in the launch options. Wow that simple... took forever. Most people get a ping of 120 and they complain it's terrible. For me a Ping of 120 is luxury... I got many friends test it and they say it runs great, only a little bit of stutter during mega mobs, but nothing to bother you, yet you always get 1 complainer thats like "Latency is terrible!" Oh go play official with your great 40 ping... Anyway I've edited a lot of Cvars, made a tougher witch, actually made a worthy tank by upping his health, editing his fist radius, making him faster than survivor, etc. I'm going to have fun with this :P
Sweet. I'm a little confused on why it works with -secure but won't work without it. Weird. At least it works for you.

 09-28-2010, 11:53 AM #9 Daemonion   Join Date: Apr 2010 Reputation: 25 Posts: 330 Hmm sorry , I can't find any scrds.exe ?_?
09-28-2010, 12:10 PM   #10
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Quote:
 Originally Posted by Daemonion Hmm sorry , I can't find any scrds.exe ?_?
You wouldn't have any scrds.exe unless you download and install the dedicated server with the hldsupdatetool. Keep in mind, this guide is meant to be used for the console version of the dedicated server and not the steam version.

 09-28-2010, 12:35 PM #11 Daemonion   Join Date: Apr 2010 Reputation: 25 Posts: 330 Oh thanks
09-28-2010, 12:42 PM   #12
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Quote:
 Originally Posted by Daemonion Oh thanks
No problem.
Are you trying to set up a server and having trouble?

 10-26-2010, 06:03 PM #13 **Slintas**      Join Date: Feb 2008 Reputation: 40 Posts: 866 Bump. When typing 'hldsupdatetool -command update -game left4dead2 -dir C:\L4D2', was it supposed to download the whole game again?
10-27-2010, 05:20 AM   #14
crash2004

Join Date: Apr 2010
Reputation: 823
Posts: 1,241
Quote:
 Originally Posted by **Slintas** Bump. When typing 'hldsupdatetool -command update -game left4dead2 -dir C:\L4D2', was it supposed to download the whole game again?
Yes, it does download the game files. You have to realize, this is for the "console" version of the dedicated server and it has to seperately download the needed files. If you were to use the "GUI" version on the same computer you play the game on, I don't think it downloads as much. The downfall of the console version is that when there is an update out, you have to run that command again to download the updates.

 11-08-2010, 06:46 PM #15 chora      Join Date: Jun 2010 Reputation: 4 Posts: 9 Hi, Which code can i use for "Healing Gnome" mutation on a dedicated server?

 Steam Users' Forums Left4Dead2 Dedicated Server Setup Guide

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

All times are GMT -7. The time now is 06:46 PM.