📚 Quick Navigation

Quick Info 🔌 Ports Installation Configuration ⚙️ Startup Parameters 🔧 Troubleshooting Performance Security

Team Fortress 2 Server Hosting Guide

Overview

Team Fortress 2 is a multiplayer game server that can be hosted on a VPS or dedicated server. This comprehensive guide covers everything you need to know about hosting a Team Fortress 2 server for your community.

Quick Info

🔌 Network Ports

Required Ports

Port Protocol Purpose
27015 UDP Game/Query (can change with -port)
27015 TCP RCON
27020 UDP SourceTV (tv_port)
27005 UDP Client port (outbound/varies)
26900 UDP Steam (outbound, -sport) (Optional)
27031-27036 UDP Steam Remote Play / P2P (outbound) (Optional)
27036-27037 TCP Steam Remote Play (inbound where applicable) (Optional)

Firewall Configuration

Allow server ports through your firewall:

# UFW (Ubuntu/Debian)
sudo ufw allow [PORT]/tcp
sudo ufw allow [PORT]/udp
sudo ufw reload

# FirewallD (CentOS/RHEL)
sudo firewall-cmd --permanent --add-port=[PORT]/tcp
sudo firewall-cmd --permanent --add-port=[PORT]/udp
sudo firewall-cmd --reload

# Windows Firewall
netsh advfirewall firewall add rule name="Team Fortress 2 Server" dir=in action=allow protocol=TCP localport=[PORT]
netsh advfirewall firewall add rule name="Team Fortress 2 Server" dir=in action=allow protocol=UDP localport=[PORT]

⚠️ Port Security Notes

Installation & Setup

System Requirements

Required Dependencies

Installation Steps

Linux (Ubuntu/Debian)

# Update system packages
sudo apt update && sudo apt upgrade -y

# Create server directory
mkdir -p ~/gameserver
cd ~/gameserver

# Download server files (method varies by game)
# Check official documentation for download links

Starting the Server

./srcds_run -console -game tf -ip 0.0.0.0 -port 27015 +map cp_dustbowl +maxplayers 24 +exec server.cfg

Windows Server

Download the server files from the official game website or through Steam (if applicable). Extract to a dedicated folder and run the server executable.

Using SteamCMD - RECOMMENDED METHOD

This game can be installed via SteamCMD using App ID: 232250

Install SteamCMD (Ubuntu/Debian)

# Update package list
sudo apt update

# Enable 32-bit architecture
sudo dpkg --add-architecture i386
sudo apt update

# Install SteamCMD
sudo apt install -y lib32gcc-s1 steamcmd

Download Server Files

# Create directory for game server
mkdir -p ~/gameservers/tf2

# Run SteamCMD and download
steamcmd +login anonymous \
         +force_install_dir ~/gameservers/tf2 \
         +app_update 232250 validate \
         +quit

# Server files are now in ~/gameservers/tf2/
cd ~/gameservers/tf2
ls -la

Windows Installation with SteamCMD

  1. Download SteamCMD from: https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
  2. Extract to C:\steamcmd\
  3. Open Command Prompt and run:
cd C:\steamcmd
steamcmd.exe +login anonymous ^
             +force_install_dir C:\gameservers\tf2 ^
             +app_update 232250 validate ^
             +quit

Server Configuration

After installation, you'll need to configure your server. Here's where to find the configuration files and what settings you can change.

Essential Settings

Server Commands

Common administrative commands (access via console or RCON):

# Kick player
kick [player_name]

# Ban player
ban [player_name]

# Change map/level (syntax varies by game)
changelevel [map_name]

# Set admin password (if supported)
setadminpassword [password]

⚙️ Startup Parameters

Command Line Template

The server uses the following command line template:

-console %GAME_TYPE% %PID_FILE% %MAP% %IP% %PORT% %PLAYERS% -condebug

Available Startup Parameters

The following parameters can be configured when starting the server:

+sv_setsteamaccount - Steam Account Login Token

Manage your steam tokens here

-sv_pure - Pure Server

A pure server is one that forces all clients on the server to use content that matches what is on the server.

Options:

-dev - Developer Messages.

Show developer messages.

-debuglog custom_error.log - Error Logging

File Errors are Logged to.

-debug - Debugging

Turns on Debugging.

+motdfile custom_motd.txt - Custom MOTD

Custom MOTD file.

+mapcyclefile custom_mapcycle.txt - Custom Mapcycle

Custom Mapcycle file.

-nomaster - Disable master server communication

No description available

-insecure - Disable Valve Anti-Cheat

Will start the server without Valve Anti-Cheat technology.

-nohltv - No SourceTV

Disables SourceTV and closes its port.

-norestart - No Restart

Won't attempt to restart failed servers.

Creating a Start Script

Linux (start.sh):

#!/bin/bash
cd /path/to/server
./server_executable [parameters] 2>&1 | tee server.log
chmod +x start.sh
./start.sh

Windows (start.bat):

@echo off
cd /d "%~dp0"
server_executable.exe [parameters]
pause

Running as a Service

Linux (systemd):

# Create service file: /etc/systemd/system/gameserver.service
[Unit]
Description=Team Fortress 2 Server
After=network.target

[Service]
Type=simple
User=gameserver
WorkingDirectory=/home/gameserver/server
ExecStart=/home/gameserver/server/start.sh
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable gameserver
sudo systemctl start gameserver
sudo systemctl status gameserver

🔧 Troubleshooting

Server Won't Start

Server not listed or query fails

Open 27015/udp and 27015/tcp; check -ip/-port; ensure sv_lan 0; verify external firewall/NAT.

Workshop maps not downloading

Ensure -authkey is present; server has internet access; use +host_workshop_collection and +workshop_start_map or fall back to FastDL.

Connection Issues

Can't Connect to Server

  1. Verify server is running: ps aux | grep server
  2. Check port is listening: netstat -an | grep [PORT]
  3. Verify firewall rules (see Ports section above)
  4. Check server IP: Use external IP, not localhost
  5. Router/NAT: Ensure port forwarding is configured

High Latency/Lag

Performance Issues

Server Lag

  1. Monitor resources: Use htop or top
  2. Check disk I/O: Use iotop
  3. Review server logs for errors or warnings
  4. Reduce player count or increase server resources
  5. Optimize configuration based on server capacity

Memory Leaks

# Monitor memory usage
free -h
top -p $(pgrep -f server)

# Restart server regularly via cron if needed
0 4 * * * /home/gameserver/restart.sh

Performance Optimization

Server Tuning

Operating System Optimization

# Increase file descriptor limits
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf

# Network tuning
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"
sysctl -w net.ipv4.tcp_wmem="4096 87380 16777216"

Monitoring

Set up monitoring to track server health:

Backup Strategy

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

# Create backup
tar -czf $BACKUP_DIR/backup_$DATE.tar.gz -C $SERVER_DIR .

# Keep only last 7 days
find $BACKUP_DIR -name "backup_*.tar.gz" -mtime +7 -delete

Security Best Practices

Firewall Configuration

# Minimal firewall - only allow necessary ports
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow [SERVER_PORT]/tcp
sudo ufw allow [SERVER_PORT]/udp
sudo ufw allow 22/tcp  # SSH
sudo ufw enable

Strong Passwords

Regular Updates

Access Control

DDoS Protection

Additional Resources

External References

Important Notes

Last updated: November 2025 | For Team Fortress 2 server hosting