How to create a Tibia OTServ on Windows with TFS: technical guide

Learn how to set up a Tibia OTServ on Windows with The Forgotten Server (TFS), MySQL and port configuration on a dedicated VPS.

Running your own OTServ is one of the most educational exercises for anyone who wants to understand game servers — you deal with the database, TCP sockets, Lua scripting and operating system administration all at once. The Forgotten Server (TFS) has been the most widely used engine in the Open Tibia scene since the mid-2010s, and the 1.x branch introduced a modern C++ codebase that makes maintenance significantly easier.

This guide walks through the complete path to get a TFS 1.5 instance running on Windows Server 2022, with MySQL configured, firewall ports open and the client connecting to the server. The persona here is the beginner or intermediate OTServ owner who prefers a Windows environment for its gentler learning curve — even if Linux offers performance advantages in the long run.

Estimated execution time: 45 to 60 minutes, accounting for binary downloads and the map files. The setup reuses precompiled builds distributed by the community, so there is no need to compile TFS from source.

Prerequisites

Before starting, confirm that you have administrative access to a Windows VPS with a dedicated public IP. OTServ does not work on environments with CGNAT or shared IPs because it needs to open inbound ports for the Tibia client to connect.

Technical prerequisites

Windows Server 2022 (or Windows 10/11 with administrative access), at least 4 GB of RAM and 2 vCPUs to sustain 200-300 players, 30 GB of free disk, and RDP (Remote Desktop) access with a user that has administrator permission. The VPS needs a dedicated IPv4 — no CGNAT.

Login port 7171/TCP
World port 7172/TCP
MySQL port 3306/TCP (local)
Minimum RAM 4 GB

Preparing the Windows environment

Before downloading TFS, install the runtime dependencies that the precompiled binaries expect to find on the system. Without them, tfs.exe fails to start with cryptic messages about missing DLLs.

01

Connect to the VPS via RDP using the public IP, the Administrator user and the password provided during provisioning. Use the standard Remote Desktop client on Windows or any RDP client you prefer.

After logging in, open PowerShell as administrator (right-click the Start menu, “Windows PowerShell (Admin)”). All the commands below run in this context.

02

Install the Visual C++ Redistributable 2015-2022 (x64), which is the runtime required by modern TFS builds:

Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "$env:TEMP\vc_redist.x64.exe"
Start-Process -FilePath "$env:TEMP\vc_redist.x64.exe" -ArgumentList "/install","/quiet","/norestart" -Wait

This package contains the C++ libraries that tfs.exe links dynamically. Without it, the executable returns the “VCRUNTIME140.dll missing” error when you try to launch it.

03

Create the folder structure where the server will live:

New-Item -ItemType Directory -Path "C:\otserv" -Force
New-Item -ItemType Directory -Path "C:\otserv\backup" -Force

Keeping the OTServ outside C:\Program Files avoids UAC write permission problems when TFS tries to generate logs or update world files.

Installing MySQL for the database

TFS uses MySQL (or MariaDB) to store accounts, characters, houses and persistent world state. Without the database running, the server will not start.

04

Download MySQL Community Server 8.0 (the MSI installer) from mysql.com/downloads. During installation, choose “Developer Default” as the setup type — this installs MySQL Server, Workbench and the connectors.

When the wizard prompts you to configure a root password, choose a strong password and store it in a password manager. You will need it within seconds.

05

Open MySQL Workbench and connect to the local instance. Run the SQL below to create the database and the dedicated TFS user:

CREATE DATABASE forgottenserver CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'otserv'@'localhost' IDENTIFIED BY 'CHANGE_THIS_STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON forgottenserver.* TO 'otserv'@'localhost';
FLUSH PRIVILEGES;

Using a dedicated user instead of root reduces risk: if TFS hits a SQL injection bug (which has happened historically in Lua scripts), the damage stays contained inside the game database.

MySQL bind

By default MySQL listens only on 127.0.0.1, which is correct for this scenario. NEVER expose port 3306 to the internet — always access the database through an SSH/RDP tunnel or strictly locally on the VPS.

Downloading and configuring TFS

With runtime and database ready, download the TFS build and import the initial schema.

06

Download the latest release of The Forgotten Server 1.5 from otland.net/forums (section “Compiled Servers — Windows”). Look for a “downgrade 8.60” build if you want the most popular classic protocol, or vanilla TFS 1.5 for the modern 12.x protocol.

Extract the ZIP into C:\otserv\. You should end up with a structure like:

C:\otserv\
  tfs.exe
  config.lua.dist
  schema.sql
  data\
  notes\
07

Import the initial schema into the database you created:

cd C:\otserv
mysql -u otserv -p forgottenserver < schema.sql

This command creates every table: accounts, players, houses, guilds, tile_store and the rest. TFS will not run without these tables in place.

08

Copy config.lua.dist to config.lua and edit it with the parameters of your server:

ip = "YOUR_PUBLIC_IP_HERE"
loginProtocolPort = 7171
gameProtocolPort = 7172
statusProtocolPort = 7171

mysqlHost = "127.0.0.1"
mysqlUser = "otserv"
mysqlPass = "CHANGE_THIS_STRONG_PASSWORD"
mysqlDatabase = "forgottenserver"
mysqlPort = 3306

serverName = "My OTServ"
ownerName = "Your Name"
worldType = "pvp"

The ip field is the most common mistake: if it stays as 127.0.0.1 (the default), the server only answers local connections and external players see “Cannot connect to login server”.

Opening firewall ports

The Windows Firewall blocks inbound connections by default. You need to create explicit rules for the TFS ports.

09

Open an admin PowerShell and create the inbound rules:

New-NetFirewallRule -DisplayName "OTServ Login" -Direction Inbound -Protocol TCP -LocalPort 7171 -Action Allow
New-NetFirewallRule -DisplayName "OTServ Game" -Direction Inbound -Protocol TCP -LocalPort 7172 -Action Allow

Confirm that the rules were created:

Get-NetFirewallRule -DisplayName "OTServ*" | Select-Object DisplayName, Enabled, Direction

You should see both rules with Enabled: True and Direction: Inbound.

Do not disable the entire firewall

Tempting for beginners as a way to “fix it once and for all”, disabling the Windows Firewall exposes RDP (port 3389), MySQL (3306) and every internal service to the internet. Keep the firewall on and create only the rules you actually need.

Starting the server and verifying

With everything configured, it is time to start TFS and validate that it works.

10

Inside C:\otserv, double-click tfs.exe (or run it from PowerShell):

cd C:\otserv
.\tfs.exe

You should see output similar to:

The Forgotten Server - Version 1.5
Loaded config.lua
Loaded items, monsters, NPCs, spells
Connected to MySQL
Loaded map
[OK] Server Online! - 127.0.0.1:7171

If a MySQL error appears, double-check mysqlPass in config.lua. If a map error appears, confirm that data/world/forgotten.otbm exists.

Verification

Confirm that the server is accepting external connections by running this from your local machine (not from the VPS):

telnet YOUR_PUBLIC_IP 7171

If the screen goes blank without an error message, the port is open and TFS is responding. Press Ctrl+] and type quit to exit.

To test with a real Tibia client, open OTClient or an adapted Tibia client, go to “Server” and set: IP = your VPS public IP, port = 7171. Create an account through an in-game command or directly via SQL and try to log in.

Troubleshooting

”Cannot connect to login server” on the client side

Most common cause: ip in config.lua is set to 127.0.0.1 or the wrong IP. Confirm the network interface IP with ipconfig and adjust. Then check whether port 7171 is really open using an external scanner such as nmap from a different machine.

TFS closes by itself when starting

Usually a missing or wrong Visual C++ Redistributable. Confirm that you installed the x64 2015-2022 package, not the x86 one. Another common cause: data/items/items.otb corrupted or from a different version than the configured protocol.

Lag or latency spikes with only a few players

It is almost always poorly optimized Lua scripts. Enable debug mode in config.lua (logFile = "logs/server.log") and audit global or event scripts firing SQL queries inside loops. On adequate hardware, TFS 1.5 comfortably sustains a few hundred players before saturating CPU.

Next steps

With the OTServ running, consider the following points to move the project forward:

  • Set up automatic MySQL backups through Windows Task Scheduler (daily SQL dump export)
  • Stand up a PHP site with login.php so modern Tibia clients can fetch server information (charlist API)
  • Add external uptime monitoring to get notified if tfs.exe crashes
  • Customize the map with Remere’s Map Editor or write your own Lua quests
  • Migrate to the modern protocol (12.x) if you want current features from official Tibia

If you are taking the server into production with a real player base, a Hostini game VPS already ships with dedicated IPv4, DDoS protection specialized for game ports (7171/7172) and low latency to Brazil — which matters a lot when your players are based there.

Frequently asked questions

Which TFS version should I choose for a new OTServ in 2026?

TFS 1.5 (downgrade 8.60 or 7.72) is the most common choice for new projects because of its modern C++17 codebase and wide availability of community scripts. TFS 1.4 is still viable if you depend on older libraries. Avoid TFS 0.4 unless you have a nostalgic reason — maintenance and community support have moved to the 1.x line.

Why does my Tibia client show 'Cannot connect to login server' even though the OTServ is running?

It is almost always one of three causes: the ip in config.lua is set to 127.0.0.1 instead of the public IP, port 7171 is not allowed through the Windows firewall, or the site login.php points to the wrong VPS IP. Check all three before touching the source code.

Can I run an OTServ on Windows or is Linux mandatory?

Windows runs OTServ without issues and is more common among beginner owners because of the familiar interface. Linux usually offers better performance per core and lower licensing cost, but it requires comfort with the command line. To get started, Windows Server 2022 is a pragmatic choice.

How many players can an OTServ handle on a VPS with 4 GB of RAM?

For TFS 1.5 with a moderate custom map, 4 GB of RAM and 2 vCPUs comfortably sustain 200-300 concurrent online players. The bottleneck usually appears in poorly optimized Lua scripts (SQL queries inside loops, heavy global events) long before the hardware itself saturates.

Do I need a dedicated IP to run an OTServ?

Yes, it is effectively mandatory. Players need a stable IP to configure in the Tibia client or OTClient. Shared IPs (CGNAT) do not allow opening ports 7171 and 7172 for inbound traffic. Every Hostini VPS comes with a dedicated IPv4 by default.

How do I protect an OTServ against DDoS attacks without hurting latency?

Use network-layer protection that filters malicious traffic before it reaches the server. OTServ uses UDP/TCP on specific ports (7171, 7172) — generic HTTP protection will not cover it. A VPS with DDoS protection specialized for games filters volumetric attacks without adding perceivable latency.

Topics:
Next steps VPS, dedicated or managed panel for FiveM, SAMP, MTA, Tibia and more.Host your game server with Hostini →
Was this tutorial helpful?
Chat on WhatsApp