Skip to main content

How to Create Your Left 4 Dead 2 Server

This guide explains how to install and configure a dedicated Left 4 Dead 2 (L4D2) server on your VPS or dedicated Linux server.

Order a Server​

To host your Left 4 Dead 2 server, HostMyServers offers several gaming-optimized options:

Prerequisites​

Resources

The resources listed below correspond to the server's requirements and do not take into account the resources already used by the operating system, installed software or other services on the machine. Allow 3 to 5 Mbps for 10 players at tickrate 30, and about three times more at tickrate 100 (requires the Tickrate Enabler extension for L4D2).

  • SSH access as root or user with sudo privileges
  • 64-bit Linux system (Debian 12/13 or Ubuntu 22.04/24.04 recommended)
  • Active firewall: nftables (recommended), iptables or ufw (use only one firewall tool at a time)
  • Minimum 2 GB of RAM
  • About 10 GB of free disk space (SSD recommended)
  • Port 27015 UDP accessible (and port 27015 TCP for RCON, from your static IP address only)

Required Configuration​

ComponentMinimumRecommended
RAM2 GB4 GB
CPU1 core2 cores
Storage10 GB10 GB SSD
Network100 Mbps500 Mbps
Network Protocol

Left 4 Dead 2 uses port 27015 over UDP for the game and over TCP for RCON access (remote administration). The TCP port must only be reachable from your IP addresses.

System Update​

sudo apt update && sudo apt upgrade -y

Installing Dependencies​

SteamCMD and the L4D2 server are 32-bit programs: 32-bit libraries are required. First check that the i386 architecture is enabled:

sudo dpkg --print-foreign-architectures

If the output is empty, run:

sudo dpkg --add-architecture i386
sudo apt update

Then install the required packages:

sudo apt install -y wget tar screen lib32gcc-s1 lib32stdc++6 lib32z1

Creating a Dedicated User​

For security reasons, create a dedicated user:

sudo adduser --disabled-password --gecos "" l4d2

Firewall Configuration​

Open port 27015 over UDP for players. Port 27015 over TCP is used for RCON: restrict it to your static IP address (replace YOUR_IP).

With UFW​

sudo ufw allow 27015/udp
sudo ufw allow from YOUR_IP to any port 27015 proto tcp
sudo ufw reload

With iptables​

sudo iptables -A INPUT -p udp --dport 27015 -j ACCEPT
sudo iptables -A INPUT -p tcp -s YOUR_IP --dport 27015 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4

Saving the rules across reboots requires the iptables-persistent package.

With nftables​

These commands use the inet filter table and the input chain, present by default in /etc/nftables.conf on Debian.

sudo nft add rule inet filter input udp dport 27015 accept
sudo nft add rule inet filter input ip saddr YOUR_IP tcp dport 27015 accept
(echo "flush ruleset"; sudo nft list ruleset) | sudo tee /etc/nftables.conf
RCON Security

Never open TCP port 27015 to everyone: it gives access to RCON. Without a static IP address, do not open this port and use an SSH tunnel instead.

Installing SteamCMD​

Log in as the l4d2 user:

sudo -u l4d2 bash
cd ~

Create the directories and download SteamCMD:

mkdir -p ~/steamcmd ~/l4d2-server
cd ~/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xzf steamcmd_linux.tar.gz

Downloading the L4D2 Server​

Start the server installation (application ID 222860). A simple app_update command is no longer enough to get a working L4D2 server on Linux: you must force the installation of the Windows platform, then the Linux platform, into the same folder:

./steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir /home/l4d2/l4d2-server +login anonymous +app_update 222860 validate +quit
./steamcmd.sh +@sSteamCmdForcePlatformType linux +force_install_dir /home/l4d2/l4d2-server +login anonymous +app_update 222860 validate +quit
Tip

If the installation stops with an error, simply run the same command again: SteamCMD resumes where it left off.

When it finishes, the message Success! App '222860' fully installed. is displayed. Check that the server launch script is present:

ls ~/l4d2-server/srcds_run

Server Configuration​

server.cfg File​

Create the configuration file:

nano ~/l4d2-server/left4dead2/cfg/server.cfg

Basic Configuration​

// Server name
hostname "My L4D2 Server"

// Server password (empty = public)
sv_password ""

// RCON password
rcon_password "ChangeMe"

// Server region
// 0: United States (East)
// 1: United States (West)
// 2: South America
// 3: Europe
// 4: Asia
// 5: Australia
// 6: Middle East
// 7: Africa
// 255: worldwide (default)
sv_region 3

// 0: server visible on the Internet, 1: local network only
sv_lan 0

// Cheat commands (0 = disabled)
sv_cheats 0

// Allows direct connection to the server (without going through a lobby)
sv_allow_lobby_connect_only 0

// Server tags, separated by commas (example: "fr,coop")
//sv_tags "fr,coop"

// Reserve the server for members of a Steam group
// 1: only group members can see and join the server
// 0: public server
// To use it, enter your Steam group ID with sv_steamgroup
sv_steamgroup_exclusive 0
//sv_steamgroup group_id

// Number of slots displayed in the server list (-1 = actual number of slots)
sv_visiblemaxplayers -1

// Zombie difficulty: Easy, Normal, Hard, Impossible
z_difficulty normal

// Allowed game modes
// If this line is ignored, SourceMod must be installed:
// then prefix the command with sm_cvar (sm_cvar sv_gametypes ...)
sv_gametypes "coop,realism,survival,versus,teamversus,scavenge,teamscavenge,mutation12,right2live"

// Enables voice communication on the server
sv_voiceenable 1

// Allows players of both teams to talk to each other (0 = no, 1 = yes)
// If the value is 1, make sure sv_voiceenable is also 1
sv_alltalk 0

// RCON security
// Ban duration (in minutes) after failed RCON access attempts
sv_rcon_banpenalty 3600

// Maximum number of failed RCON access attempts before banning
sv_rcon_maxfailures 3

// Minimum number of failed RCON access attempts before banning
sv_rcon_minfailures 1

// Time window (in seconds) over which failed RCON access attempts are counted
sv_rcon_minfailuretime 10

// Player file verification
// Warning: with custom extensions or campaigns,
// these values kick players whose files differ (set them to 0)
sv_pure 2
sv_consistency 1

// Kicks players who do not have the original game files
sv_pure_kick_clients 1

// Allows (1) or disallows (0) the wait command in players' cfg files
sv_allow_wait_command 0

// Enables (1) or disables (0) the display of the message of the day (MOTD)
motd_enabled 1

// Logs
log on
sv_logecho 0
sv_logfile 1
sv_log_onefile 0
sv_logbans 1
sv_logflush 0
sv_logsdir logs

// Ban management
exec banned_user.cfg
exec banned_ip.cfg

// Generates the ban files above if they do not exist
writeid
writeip
Direct Connection

By default, a dedicated L4D2 server only accepts connections coming through a lobby. Without the sv_allow_lobby_connect_only 0 line, players will not be able to join your server directly or through the server list.

Security

Choose a long and unique rcon_password. Anyone who knows it can administer your server.

Game Modes and Maps​

Game Modes​

The mode is chosen at launch with +mp_gamemode:

ModeDescriptionPlayers
coopCooperative campaign4
realismCooperative without glow or hints4
versusSurvivors versus infected8
survivalWithstand waves of infected4
scavengeCollect gas cans8

First Map of Each Campaign​

CampaignStarting Map
Dead Centerc1m1_hotel
Dark Carnivalc2m1_highway
Swamp Feverc3m1_plankcountry
Hard Rainc4m1_milltown_a
The Parishc5m1_waterfront
The Passingc6m1_riverbank
The Sacrificec7m1_docks
No Mercyc8m1_apartment
Crash Coursec9m1_alleys
Death Tollc10m1_caves
Dead Airc11m1_greenhouse
Blood Harvestc12m1_hilltop
Cold Streamc13m1_alleys
The Last Standc14m1_junkyard

GSLT Token (optional)​

GSLT Token

The GSLT (Game Server Login Token) is not mandatory but recommended: it allows your server to be listed among Steam's public servers.

To generate it, log in to your Steam account and go to the Steam Game Server Account Management.

Creating the token has a few prerequisites:

  • Your Steam account must not be community-banned or locked
  • Your Steam account must not be limited
  • Your Steam account must have a registered phone number
  • Your Steam account must own the game for which you are creating a game server account
  • Your Steam account can create up to 1000 game server accounts

In the App ID of the base game field, enter 550. You can add a memo to remind you which server it is for, then finish by clicking the Create button.

To use the token, add it to the launch line:

+sv_setsteamaccount YOUR_TOKEN
Tip

Add the parameter to all your launch lines: the first launch, the ExecStart line of the systemd service and the command launched with screen.

First Launch​

cd ~/l4d2-server
./srcds_run -game left4dead2 -console +mp_gamemode coop +map c1m1_hotel +maxplayers 8 -port 27015

Once startup is complete, the console displays the status of the connection to the Steam servers. To stop the server, type quit.

Launch Optimization​

Launch Parameters​

ParameterDescription
-game left4dead2Game to launch (required)
+mp_gamemodeGame mode at startup
+mapStarting map
+maxplayersMaximum number of players
-portServer port (27015 by default)
-ipIP address to listen on
-tickrate 100Simulation frequency (30 by default). Increases CPU load and requires the Tickrate Enabler extension to unlock the tickrate
-norestartPrevents the script from restarting the server if it stops (useful with systemd)
-consoleRuns in console mode
-debuglog file_nameSaves debug output to the file
-highMaximum priority for the server process
-insecureDisables VAC protection (see the warning below)
+sv_setsteamaccountGSLT token (optional, see the dedicated section)
-insecure Parameter

-insecure disables VAC protection: only use this parameter for testing, as it leaves the door open to cheaters.

Tip

Make sure to leave free resources for the operating system and installed software.

Changing the Port​

./srcds_run -game left4dead2 -console +mp_gamemode coop +map c1m1_hotel +maxplayers 8 -port 27016

Don't forget to open the new port in the firewall.

File Structure​

PathDescription
left4dead2/cfg/Configuration files
left4dead2/cfg/server.cfgMain configuration
left4dead2/cfg/banned_user.cfgBanned players (SteamID)
left4dead2/cfg/banned_ip.cfgBanned IP addresses
left4dead2/addons/Extensions and custom campaigns
left4dead2/logs/Log files

Configuration as systemd Service​

Create the Service File​

Exit the l4d2 user session (exit) to return to your administrator account, then create the service file:

sudo nano /etc/systemd/system/l4d2.service

File content:

[Unit]
Description=Left 4 Dead 2 Server
After=network.target

[Service]
Type=simple
User=l4d2
Group=l4d2
WorkingDirectory=/home/l4d2/l4d2-server
Environment=TERM=xterm
ExecStart=/home/l4d2/l4d2-server/srcds_run -game left4dead2 -console -norestart +mp_gamemode coop +map c1m1_hotel +maxplayers 8 -port 27015
Restart=on-failure
RestartSec=20

[Install]
WantedBy=multi-user.target

Enable and Start the Service​

sudo systemctl daemon-reload
sudo systemctl enable l4d2.service
sudo systemctl start l4d2.service

Management Commands​

# Check status
sudo systemctl status l4d2.service

# Stop server
sudo systemctl stop l4d2.service

# Restart server
sudo systemctl restart l4d2.service

# View logs
sudo journalctl -u l4d2.service -f
Server Console

With systemd, the server console is not interactive. To send commands, use RCON from the game or launch the server with screen (see below).

Launching with screen (alternative)​

Only One Launch Mode

If the systemd service is started, stop it first (sudo systemctl stop l4d2.service): two servers cannot use the same port.

sudo -u l4d2 bash
cd ~/l4d2-server
screen -S l4d2
./srcds_run -game left4dead2 -console +mp_gamemode coop +map c1m1_hotel +maxplayers 8 -port 27015

To detach: Ctrl+A then D

To return: screen -r l4d2

Launching in the Background with a Log​

sudo -u l4d2 bash
cd ~/l4d2-server
screen -AdmSL l4d2 ./srcds_run -game left4dead2 -console +mp_gamemode coop +map c1m1_hotel +maxplayers 8 -port 27015
OptionDescription
-AAdapts the window to the terminal size
-d -mStarts the session detached, in the background
-S l4d2Session name
-LSaves the server output to a log file

The screenlog.0 file is created in the folder where the command is run (~/l4d2-server) and contains all the server-side output. To follow it live:

tail -f ~/l4d2-server/screenlog.0

If an error occurs at startup, this is the first file to check. To return to the server console: screen -r l4d2

Tip

The screenlog.0 file grows with each launch. Remember to purge or delete it regularly.

Server Update​

Stop the Server​

sudo systemctl stop l4d2.service

Download the New Version​

As for the installation, update the Windows platform, then the Linux platform:

sudo -u l4d2 bash
cd ~/steamcmd
./steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir /home/l4d2/l4d2-server +login anonymous +app_update 222860 validate +quit
./steamcmd.sh +@sSteamCmdForcePlatformType linux +force_install_dir /home/l4d2/l4d2-server +login anonymous +app_update 222860 validate +quit
exit

Restart the Server​

sudo systemctl start l4d2.service

Console Commands​

These commands are used in the server console or via RCON.

CommandDescription
statusDisplays connected players and their ID
changelevel <map>Change the map
kick <player>Kick a player
kickid <userid>Kick a player by their ID
banid <minutes> <steamid> kickBan a player (0 = permanent)
writeidSave the list of banned players to banned_user.cfg
z_difficulty <level>Change the difficulty
say <message>Send a message to all players
exec server.cfgReload the configuration
quitStop the server

Using RCON from the Game​

Your IP address must be allowed on TCP port 27015 in the firewall.

In the game console:

rcon_address SERVER_IP:27015
rcon_password YourPassword
rcon status

Automatic Backup​

Backup Script​

sudo nano /home/l4d2/backup.sh
#!/bin/bash
BACKUP_DIR="/home/l4d2/backups"
SERVER_DIR="/home/l4d2/l4d2-server"
DATE=$(date +%Y-%m-%d_%H-%M-%S)

mkdir -p $BACKUP_DIR

# Backup the configuration
tar -czf $BACKUP_DIR/l4d2_$DATE.tar.gz -C $SERVER_DIR left4dead2/cfg

# Delete backups older than 7 days
find $BACKUP_DIR -name "l4d2_*.tar.gz" -mtime +7 -delete

echo "Backup completed: l4d2_$DATE.tar.gz"
sudo chown l4d2:l4d2 /home/l4d2/backup.sh
sudo chmod +x /home/l4d2/backup.sh
Tip

If you install extensions or custom campaigns, add left4dead2/addons to the tar command.

Schedule Backup​

sudo crontab -u l4d2 -e

Add:

# Daily backup at 4 AM
0 4 * * * /home/l4d2/backup.sh

Connecting to the Server​

Players can connect via:

  1. Launch Left 4 Dead 2
  2. Open the game console (enabled in the game options)
  3. Type: connect SERVER_IP:27015
  4. If a password is configured: password YourPassword before connecting

You can also add the server to your Steam favorites (View menu, Servers, Favorites tab).

Troubleshooting​

Server won't start​

  • Check the logs: sudo journalctl -u l4d2.service -n 100
  • Check that the installation is complete (run both app_update commands again) and that the ~/l4d2-server/srcds_run file exists
  • Look for a missing library: ldd ~/l4d2-server/srcds_linux | grep "not found", then install the corresponding 32-bit package

libtinfo.so.5 or libncurses.so.5 Warning​

If the message WARNING: Failed to load 32-bit libtinfo.so.5 or libncurses.so.5 is displayed at startup despite the dependencies being installed, create symbolic links to the version 6 files:

sudo ln -sf /usr/lib/i386-linux-gnu/libtinfo.so.6 /usr/lib/i386-linux-gnu/libtinfo.so.5
sudo ln -sf /usr/lib/i386-linux-gnu/libncurses.so.6 /usr/lib/i386-linux-gnu/libncurses.so.5

If the .so.6 files do not exist, first install the libncurses6:i386 package.

steamclient.so and steamerrorreporter Errors​

Log in as the l4d2 user, then create the links to the SteamCMD files:

sudo -u l4d2 bash
mkdir -p ~/.steam/sdk32
ln -sf ~/steamcmd/linux32/steamclient.so ~/.steam/sdk32/steamclient.so
ln -sf ~/steamcmd/linux32/steamerrorreporter ~/l4d2-server/bin/steamerrorreporter
exit

Players can't connect​

  • Check that sv_allow_lobby_connect_only 0 is set in server.cfg

  • Check that port 27015 is open over UDP:

    sudo ufw status
    sudo iptables -L INPUT -n --line-numbers | grep 27015
    sudo nft list ruleset | grep 27015
  • Check that the server is listening: ss -ulnp | grep 27015

  • Test from another machine with nc -zvu SERVER_IP 27015

The server doesn't appear in the list​

  • Check that sv_lan 0 is properly set in server.cfg
  • Check that sv_steamgroup_exclusive is set to 0 (at 1, the server is reserved for members of a Steam group)
  • Wait a few minutes after startup
  • Check that the server has Internet access
  • Add a GSLT token with +sv_setsteamaccount to be listed among the public servers

Performance Issues​

  • Remove the -tickrate option if you increased it
  • Disable unnecessary extensions in left4dead2/addons
  • Schedule regular restarts

FAQ​

Which ports need to be opened?​

In addition to the server port (27015 over UDP), these ports are required by Steam. They allow the server to receive replies from the Steam servers when your firewall blocks incoming traffic by default:

UFW:

sudo ufw allow proto udp from any port 27000:27030 to any port 1025:65535
sudo ufw allow proto udp from any port 4380 to any port 1025:65535
sudo ufw reload

iptables:

sudo iptables -A INPUT -p udp -m udp --sport 27000:27030 --dport 1025:65535 -j ACCEPT
sudo iptables -A INPUT -p udp -m udp --sport 4380 --dport 1025:65535 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4

nftables:

sudo nft add rule inet filter input udp sport 27000-27030 udp dport 1025-65535 accept
sudo nft add rule inet filter input udp sport 4380 udp dport 1025-65535 accept
(echo "flush ruleset"; sudo nft list ruleset) | sudo tee /etc/nftables.conf

I get "Permission denied" when running ./steamcmd.sh​

Apply a chmod:

chmod +x /home/l4d2/steamcmd/linux32/steamcmd && chmod +x /home/l4d2/steamcmd/steamcmd.sh

My server stays frozen on "Network: IP, mode MP, dedicated Yes, ports 27015 SV / 27005 CL"​

Check that the port is not already in use by another process:

sudo lsof -i :27015

If the port is free, check that the Steam rules from the first question are properly applied.

I get the message "WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'"​

This is not a real problem: only some international characters may display incorrectly. To fix it:

sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8

If the locale-gen command is not found, first install the locales package with sudo apt install -y locales.

I get a ulimit error (no permission / can not open file)​

Set the open files limit to 2048, the value recommended by Valve. For the current session, before launching the server:

ulimit -n 2048

With systemd, add this line to the [Service] section of the service file, then reload and restart:

LimitNOFILE=2048
sudo systemctl daemon-reload
sudo systemctl restart l4d2.service