How to Change the Port of a CS 1.6 Server (27015 to Anything)

May 21, 2025 Daemon666 8 min read

Every CS 1.6 server listens on UDP 27015 by default. You change that when you run more than one server on a single machine, when a host has already claimed 27015, or when you simply want a memorable port. The important thing to get right first: the port is bound at the moment the engine starts its network socket, which is before server.cfg is ever read, so the port cannot be set from a cvar in that file. It is a launch parameter.

1. Set the port with -port on the command line

Pass -port to hlds_run (or hlds.exe) with the UDP port you want:

./hlds_run -game cstrike -port 27016 +map de_dust2 +maxplayers 20 +sv_lan 0

On Windows the same flag applies to the shortcut or batch file:

hlds.exe -console -game cstrike -port 27016 +map de_dust2 +maxplayers 20

That single flag moves both the game traffic and the RCON channel to the new port, because CS 1.6 RCON runs over the same UDP port as the game. There is no separate RCON port to configure. See the full list of HLDS command-line parameters for the flags that pair with this one.

2. Why a cvar in server.cfg does not work

People try to add a port line to server.cfg and are surprised when the server still answers on 27015. The socket is already open by the time server.cfg executes, so changing the value there does nothing for the current session. Use -port at launch, every time. If you run through a systemd service, put -port in the ExecStart line, not in a config.

3. Open the new port in the firewall

A moved port is useless if the firewall still only permits 27015. Allow the new UDP port both inbound and outbound:

ufw allow 27016/udp

Remember CS 1.6 is UDP, not TCP — a TCP rule lets nothing through. The firewall ports guide covers the exact rules and the master-server ports you also need open.

4. Bind the address too when the box has several IPs

On a machine with multiple public addresses, pair -port with -ip so the server binds the right interface:

./hlds_run -game cstrike -ip 203.0.113.10 -port 27016 +maxplayers 20 +map de_dust2

Without -ip the engine binds all interfaces on that port, which is usually fine on a single-IP VPS but a source of "couldn't allocate" errors when two servers fight over the same address and port.

5. Running several servers on one machine

Each server needs a unique port. The convention is to step by one or more from 27015:

# server A
./hlds_run -game cstrike -port 27015 +maxplayers 20 +map de_dust2
# server B
./hlds_run -game cstrike -port 27016 +maxplayers 24 +map de_inferno
# server C
./hlds_run -game cstrike -port 27017 +maxplayers 32 +map cs_office

Give each its own directory or at least its own logs so you can tell them apart. All of them still need sv_lan 0 to reach the master list, and each registers separately once its port is reachable.

6. How players connect to the new port

Clients must include the port when it is not 27015. In the client console:

connect 203.0.113.10:27016

The default 27015 is implied when no port is given, which is why a moved server that "does not show up" for a friend is often just a missing :port in their connect string.

Common errors

  • "Couldn't allocate dedicated server IP port" — another process already holds that port, or two servers were told the same one. Pick a free port and check with ss -lunp | grep 2701. The dedicated fix is in couldn't allocate server IP/port.
  • Server still on 27015 — you set port in server.cfg instead of passing -port at launch. The cvar is read too late.
  • Server runs but nobody can join — the new UDP port is not open in the firewall or not forwarded on the router.
  • Not in the master list after the move — confirm sv_lan 0 and that the new port is reachable from outside; see server not in master list.
  • Two servers randomly conflict — both bound all interfaces on overlapping ports. Give each a distinct -port and, on multi-IP boxes, a distinct -ip.

Verification

Start the server, then from the host confirm it is listening on the port you chose:

ss -lunp | grep 27016

You should see the hlds process bound to *:27016 (or your specific IP). Then connect from a client with connect ip:27016 and run status — the udp/ip line should show your new port. Once external players can join and the server appears in the browser, the move is complete.

Участники: Daemon666 ✦
Поделиться: