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.
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.
- Performance VPS - Dedicated resources and fast processors, ideal for FiveM
- NVMe VPS - For a small server or a test server
- Eco Dedicated Servers - For servers with many players
- Performance Dedicated Servers - Maximum performance
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
sudo apt update && sudo apt upgrade -yInstalling Dependencies
The txAdmin documentation runs the server in screen, and xz-utils is used to extract the archive:
sudo apt install -y curl tar xz-utils screen ca-certificatesCreating a Dedicated User
The server must never run as root. Create a dedicated user:
sudo adduser --disabled-password --gecos "" fivemPorts 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.
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp
sudo ufw allow from YOUR_IP to any port 40120 proto tcp
sudo ufw reloadWith iptables
The last rule blocks txAdmin for all other addresses while keeping the local SSH tunnel working:
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.v4Saving 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 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.confCreating the Cfx.re License Key
Each server needs a free license key, which starts with cfxk_.
- Log in to the Cfx.re portal with your account.
- Open the server registration keys page.
- Click the + button, fill in the requested information (server name, tagline, description and language), then click Generate Key.
- 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:
sudo -iu fivem
mkdir -p ~/txDataCreate a script that downloads the recommended version of FXServer. It will also be used for updates:
nano ~/update-fxserver.sh#!/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:
chmod +x ~/update-fxserver.sh
~/update-fxserver.sh
ls ~/server
exitThe ~/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
sudo nano /etc/systemd/system/fivem.serviceFile content:
[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.targetDo 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
sudo systemctl daemon-reload
sudo systemctl enable fivem.service
sudo systemctl start fivem.serviceManagement Commands
# 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.logConfiguration 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:
ssh -L 40120:127.0.0.1:40120 YOUR_USER@SERVER_IPKeep 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:
sudo grep -a -A2 'PIN below' /home/fivem/fxserver.logSetup Wizard
- Enter the PIN code, then click Link Account and log in with your Cfx.re account.
- Choose the txAdmin administrator password.
- Give your server a name.
- 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).
- Keep the suggested destination folder, then move on to the Recipe Deployer.
- Paste your
cfxk_key, fill in the database details if the template requires a database, then click Run Recipe. - 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:
sudo apt install -y mariadb-server
sudo systemctl enable --now mariadbGenerate a password without special characters, because it will be placed in a connection string:
openssl rand -hex 16Create the database and its user, replacing GENERATED_PASSWORD with this password:
sudo mariadbCREATE 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:
set mysql_connection_string "mysql://fivem:GENERATED_PASSWORD@127.0.0.1/fivem?charset=utf8mb4"Verify the Server
Check that the ports are listening:
sudo ss -tulpn | grep -E ':(30120|40120)\b'From your computer, this address should return the server information in JSON format:
http://SERVER_IP:30120/info.jsonAlso check, from a connection other than YOUR_IP, that http://SERVER_IP:40120 does not respond.
Connecting to Server
- Launch FiveM.
- Open the console with the
F8key. - 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:
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:
sudo systemctl stop fivem.service
sudo -iu fivem /home/fivem/update-fxserver.sh
sudo systemctl start fivem.serviceMake 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
sudo nano /usr/local/sbin/backup-fivem.shLeave DB_NAME empty if you do not use MariaDB:
#!/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 -deletesudo chmod 750 /usr/local/sbin/backup-fivem.sh
sudo /usr/local/sbin/backup-fivem.sh
sudo ls -lh /home/fivem/backupsSchedule Backup
sudo nano /etc/cron.d/fivem-backup# Backup every night at 5:30 AM
30 5 * * * root /usr/local/sbin/backup-fivem.shRegularly copy these archives off the server.
Restore a Backup
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.serviceReplace 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:
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.jsonresponds - Check that 30120 is open on TCP and UDP
- Check that the
sv_master1 ""line inserver.cfgis 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 withsudo systemctl status mariadb, and make sure you use127.0.0.1as the hostAccess 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