EN

Game servers

How to Create a FiveM Server with txAdmin

Complete guide to install a FiveM server on a VPS or dedicated Linux server with txAdmin: Cfx.re license key, systemd service, firewall, MariaDB database, updates and backups.

10 min read, updated on 18 November 2026

On this page

Your values

Enter them once and the commands in this guide update.

This guide explains how to install a FiveM server (FXServer) on your VPS or dedicated Linux server, configure it with txAdmin, its web administration interface, and run it as a service under a dedicated user.

Order a Server

To host your FiveM server, HostMyServers offers several options. A server with a roleplay-type framework and many resources requires a fast processor and memory.

Prerequisites

  • SSH access as root or user with sudo privileges
  • 64-bit x86_64 Linux system (Debian 12/13 or Ubuntu 22.04/24.04); ARM processors are not supported
  • Active firewall: nftables, iptables or ufw (use only one tool at a time)
  • A Cfx.re account to create the server license key
  • A legitimate copy of GTA V for each player
  • Ports 30120 TCP and UDP accessible, and port 40120 TCP (txAdmin) restricted to your IP address

Required Configuration

Cfx.re does not publish minimum requirements for the server. The values below are guidelines to adapt to your resources and number of players.

Usage CPU RAM Storage
Basic or test server 2 fast cores 4 GB 20 GB SSD
Roleplay framework, up to 48 players 4 fast cores 8 GB 40 GB NVMe SSD
Busy server, many resources 6 cores or more 16 GB and more 80 GB NVMe SSD

System Update

Terminal
sudo apt update && sudo apt upgrade -y

Installing Dependencies

The txAdmin documentation runs the server in screen, and xz-utils is used to extract the archive:

Terminal
sudo apt install -y curl tar xz-utils screen ca-certificates

Creating a Dedicated User

The server must never run as root. Create a dedicated user:

Terminal
sudo adduser --disabled-password --gecos "" fivem

Ports Used

Port Protocol Usage Access
30120 TCP and UDP Game (player connections and server information) Public
40120 TCP txAdmin web interface Your IP address only
3306 TCP MariaDB, if you install it Local only, do not open it

Firewall Configuration

Open the game port and restrict txAdmin to your fixed IP address: replace YOUR_IP. If you do not have a fixed address, do not create the rule allowing YOUR_IP and use the SSH tunnel described below instead.

With UFW

Once enabled, UFW denies incoming connections by default. Check that it is active with sudo ufw status.

Terminal
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp
sudo ufw allow from YOUR_IP to any port 40120 proto tcp
sudo ufw reload

With iptables

The last rule blocks txAdmin for all other addresses while keeping the local SSH tunnel working:

Terminal
sudo iptables -A INPUT -p tcp --dport 30120 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 30120 -j ACCEPT
sudo iptables -A INPUT -p tcp -s YOUR_IP --dport 40120 -j ACCEPT
sudo iptables -A INPUT ! -i lo -p tcp --dport 40120 -j DROP
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.

Terminal
sudo nft add rule inet filter input tcp dport 30120 accept
sudo nft add rule inet filter input udp dport 30120 accept
sudo nft add rule inet filter input ip saddr YOUR_IP tcp dport 40120 accept
sudo nft add rule inet filter input iifname != "lo" tcp dport 40120 drop
(echo "flush ruleset"; sudo nft list ruleset) | sudo tee /etc/nftables.conf

Creating the Cfx.re License Key

Each server needs a free license key, which starts with cfxk_.

  1. Log in to the Cfx.re portal with your account.
  2. Open the server registration keys page.
  3. Click the + button, fill in the requested information (server name, tagline, description and language), then click Generate Key.
  4. Copy the key with Copy Key and keep it for the configuration step.

Installing FXServer

Log in as the fivem user and create the txAdmin data folder:

Terminal
sudo -iu fivem
mkdir -p ~/txData

Create a script that downloads the recommended version of FXServer. It will also be used for updates:

Terminal
nano ~/update-fxserver.sh
Terminal
#!/bin/bash
set -euo pipefail

API="https://changelogs-live.fivem.net/api/changelog/versions/linux/server"
URL=$(curl -fsSL "$API" | grep -o '"recommended_download":"[^"]*"' | cut -d'"' -f4)
[ -n "$URL" ] || { echo "Download URL not found" >&2; exit 1; }

TMP=$(mktemp -d "$HOME/fxserver.XXXXXX")
trap 'rm -rf "$TMP"' EXIT

curl -fL -o "$TMP/fx.tar.xz" "$URL"
tar -xJf "$TMP/fx.tar.xz" -C "$TMP"
rm -f "$TMP/fx.tar.xz"

rm -rf "$HOME/server"
mkdir -p "$HOME/server"
mv "$TMP"/* "$HOME/server/"

echo "Installed version: $URL"

Run it, then exit the fivem user's session:

Terminal
chmod +x ~/update-fxserver.sh
~/update-fxserver.sh
ls ~/server
exit

The ~/server folder must contain run.sh and alpine. If you prefer to choose the version yourself, the archives are listed on the official download page.

Configuration as systemd Service

Create Service File

Terminal
sudo nano /etc/systemd/system/fivem.service

File content:

Configuration
[Unit]
Description=FiveM Server (FXServer + txAdmin)
After=network-online.target mariadb.service
Wants=network-online.target

[Service]
Type=simple
User=fivem
Group=fivem
WorkingDirectory=/home/fivem/txData
Environment=TERM=xterm
Environment=TXHOST_DATA_PATH=/home/fivem/txData
Environment=TXHOST_TXA_PORT=40120
Environment=TXHOST_GAME_NAME=fivem
ExecStartPre=/usr/bin/truncate -s 0 /home/fivem/fxserver.log
ExecStart=/usr/bin/screen -L -Logfile /home/fivem/fxserver.log -DmS fivem /home/fivem/server/run.sh
Restart=always
RestartSec=15
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Do not pass a +exec argument to run.sh: it would prevent txAdmin from starting.

Variable Role
TXHOST_DATA_PATH txAdmin data folder, kept separate from the FXServer files so that it survives updates
TXHOST_TXA_PORT Web interface port (40120 by default)
TXHOST_GAME_NAME Limits txAdmin to FiveM templates

Enable and Start Service

Terminal
sudo systemctl daemon-reload
sudo systemctl enable fivem.service
sudo systemctl start fivem.service

Management Commands

Terminal
# Check status
sudo systemctl status fivem.service

# Stop server
sudo systemctl stop fivem.service

# Restart server
sudo systemctl restart fivem.service

# Follow the console
sudo tail -f /home/fivem/fxserver.log

Configuration with txAdmin

Accessing the Interface

The safest method is an SSH tunnel, because the traffic stays encrypted and no administration port needs to be opened. From your computer:

Terminal
ssh -L 40120:127.0.0.1:40120 YOUR_USER@SERVER_IP

Keep this session open, then open http://127.0.0.1:40120 in your browser. If you allowed YOUR_IP in the firewall, you can also use http://SERVER_IP:40120.

Retrieving the PIN Code

On first startup, txAdmin displays a 4-digit PIN code. Wait about fifteen seconds, then display it on the server:

Terminal
sudo grep -a -A2 'PIN below' /home/fivem/fxserver.log

Setup Wizard

  1. Enter the PIN code, then click Link Account and log in with your Cfx.re account.
  2. Choose the txAdmin administrator password.
  3. Give your server a name.
  4. Select Popular Recipes, then a template. For a simple server, pick the Cfx.re basic template (FiveM Basic Server, sometimes shown as CFX Default FiveM).
  5. Keep the suggested destination folder, then move on to the Recipe Deployer.
  6. Paste your cfxk_ key, fill in the database details if the template requires a database, then click Run Recipe.
  7. When the deployment finishes, click Save & Run Server.

The server files are created in a subfolder of /home/fivem/txData whose name ends in .base. txAdmin shows the exact path.

MariaDB Database (if needed)

The basic template does not need a database. Frameworks such as ESX Legacy or Qbox require one, and oxmysql, the resource they use to connect to it, recommends MariaDB. Install it before starting the deployment:

Terminal
sudo apt install -y mariadb-server
sudo systemctl enable --now mariadb

Generate a password without special characters, because it will be placed in a connection string:

Terminal
openssl rand -hex 16

Create the database and its user, replacing GENERATED_PASSWORD with this password:

Terminal
sudo mariadb
SQL
CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'GENERATED_PASSWORD';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Then, in the txAdmin deployment, enter:

Field Value
Host 127.0.0.1
Port 3306
User fivem
Password The generated password
Database fivem

txAdmin writes the connection to server.cfg, in this form:

Text
set mysql_connection_string "mysql://fivem:GENERATED_PASSWORD@127.0.0.1/fivem?charset=utf8mb4"

Verify the Server

Check that the ports are listening:

Terminal
sudo ss -tulpn | grep -E ':(30120|40120)\b'

From your computer, this address should return the server information in JSON format:

Text
http://SERVER_IP:30120/info.json

Also check, from a connection other than YOUR_IP, that http://SERVER_IP:40120 does not respond.

Connecting to Server

  1. Launch FiveM.
  2. Open the console with the F8 key.
  3. Type: connect SERVER_IP:30120

A new server can take up to 8 minutes to appear in the public list.

Administration

Most tasks are handled from txAdmin:

Menu Usage
Live Console Live server console
CFG Editor Editing server.cfg
Resources Listing and managing resources
Players Players, warnings and bans
Admins Administrator accounts and permissions
Settings Settings, including the restart schedule (Restart Schedule)
Master Actions Actions reserved for the main account

In game, open the console with F8 and type tx to display the txAdmin menu.

A few useful server.cfg settings, to edit in CFG Editor:

Text
sv_maxclients 48
sv_endpointPrivacy true
Parameter Description
sv_maxclients Maximum number of players, depending on your subscription
sv_endpointPrivacy Hides player IP addresses in public information

Cfx.re states that the server name and description are now managed from the portal. Leave rcon_password unset: RCON then stays disabled, and Live Console replaces it.

Server Update

The script installs the latest recommended version without touching txData:

Terminal
sudo systemctl stop fivem.service
sudo -iu fivem /home/fivem/update-fxserver.sh
sudo systemctl start fivem.service

Make a backup before each update.

Automatic Backup

txData contains your resources, server.cfg and the txAdmin accounts. Backups therefore contain secrets: keep them private.

Backup Script

Terminal
sudo nano /usr/local/sbin/backup-fivem.sh

Leave DB_NAME empty if you do not use MariaDB:

Terminal
#!/bin/bash
set -euo pipefail
umask 027

BACKUP_DIR="/home/fivem/backups"
DB_NAME="fivem"
DATE=$(date +%Y-%m-%d_%H-%M-%S)

install -d -o fivem -g fivem -m 750 "$BACKUP_DIR"

# Server and txAdmin files, excluding caches
tar --exclude='*/cache' -czf "$BACKUP_DIR/fivem_$DATE.tar.gz" -C /home/fivem txData

# Database
if [ -n "$DB_NAME" ]; then
    mariadb-dump --single-transaction "$DB_NAME" | gzip > "$BACKUP_DIR/fivem_db_$DATE.sql.gz"
fi

chown fivem:fivem "$BACKUP_DIR"/fivem_*"$DATE"*

# Delete backups older than 7 days
find "$BACKUP_DIR" -name "fivem_*.gz" -mtime +7 -delete
Terminal
sudo chmod 750 /usr/local/sbin/backup-fivem.sh
sudo /usr/local/sbin/backup-fivem.sh
sudo ls -lh /home/fivem/backups

Schedule Backup

Terminal
sudo nano /etc/cron.d/fivem-backup
Text
# Backup every night at 5:30 AM
30 5 * * * root /usr/local/sbin/backup-fivem.sh

Regularly copy these archives off the server.

Restore a Backup

Terminal
sudo systemctl stop fivem.service
sudo mv /home/fivem/txData /home/fivem/txData.old
sudo -u fivem tar -xzf /home/fivem/backups/fivem_DATE.tar.gz -C /home/fivem
zcat /home/fivem/backups/fivem_db_DATE.sql.gz | sudo mariadb fivem
sudo systemctl start fivem.service

Replace DATE with the date of the archive, and skip the zcat line if you do not use a database.

Troubleshooting

Service won't start

  • Check the service: sudo journalctl -u fivem.service -n 50
  • Check the console: sudo tail -n 100 /home/fivem/fxserver.log
  • Check that the architecture is x86_64: uname -m
  • Check the permissions: sudo chown -R fivem:fivem /home/fivem

Failed to start HTTP server, port 40120 is already in use

Another txAdmin instance is already using the port. Identify it:

Terminal
sudo ss -ltnp | grep ':40120'

If you started run.sh manually, stop that process before starting the service.

PIN code not found

The code is only displayed as long as no administrator exists. Restart the service, wait a few seconds, then run the grep command again. If an account already exists, log in with it.

If you have lost the main account's password, stop the service, rename /home/fivem/txData/admins.json, then restart: txAdmin offers to create an administrator again.

No license key was specified

The key is missing or incorrect. Check the sv_licenseKey line in CFG Editor, or regenerate the key on the Cfx.re portal.

Server doesn't appear in the list

  • Test the direct connection with connect SERVER_IP:30120
  • Check that http://SERVER_IP:30120/info.json responds
  • Check that 30120 is open on TCP and UDP
  • Check that the sv_master1 "" line in server.cfg is commented out with #
  • Wait up to 8 minutes after startup

Server remains limited to 48 players

You need an Element Club Argentum subscription or higher, an up-to-date server, then a suitable sv_maxclients value and a restart.

Database connection error

  • ECONNREFUSED: check that MariaDB is running with sudo systemctl status mariadb, and make sure you use 127.0.0.1 as the host
  • Access denied: check the user, the password and the database name
  • If the password contains special characters, replace it with a value generated with openssl rand -hex 16

Cannot access txAdmin

  • Check that the service is running and that port 40120 is listening
  • Check that your public IP address still matches YOUR_IP
  • Use the SSH tunnel, which does not depend on the firewall rule