To run a FiveM server on a Linux VPS, download the Linux artifacts (fx.tar.xz) from the official Server Download page, extract them and start run.sh without +exec, so txAdmin opens on port 40120. Then open port 30120 TCP and UDP for players and 40120 TCP for txAdmin, install MariaDB if your framework needs a database and run the server inside tmux or as a systemd service so it keeps running after you close SSH. The commands below use Ubuntu or Debian.
Cfx.re notes that the Linux version of FXServer is provided "as a courtesy port" and that issues are more likely to be fixed on the Windows version. Keep that in mind when you report a bug.
What you need before you start
- A 64-bit Linux VPS with root or sudo access.
- A license key from the Cfx.re Portal.
- Enough RAM for your project. As a rough reference shared by server owners on the Cfx.re forum, a light server on Linux runs in about 4 GB, while roleplay servers with many add-on vehicles and clothing, plus the database on the same machine, are usually given 8 to 16 GB. These figures are orientative: txAdmin shows the real CPU and RAM usage, so measure before you resize.
How to install FXServer on Linux
Run the server with its own user, not as root:
sudo apt update
sudo apt install -y xz-utils wget git tmux
sudo adduser --disabled-password --gecos "" fivem
sudo -iu fivem
mkdir -p ~/FXServer/server && cd ~/FXServer/server
wget "RECOMMENDED_FX_TAR_XZ_URL"
tar xf fx.tar.xz && rm fx.tar.xz
Get the URL from the download page by choosing FiveM / RedM, Linux and the Recommended branch. It points to runtime.fivem.net/artifacts/fivem/build_proot_linux/master/. The archive contains an alpine folder and the run.sh script; to learn when and how to update it, see FiveM artifacts and game builds. Then type exit to return to your administrator user, because the firewall and database steps below need sudo.
Which ports does a FiveM server use?
- 30120 TCP and UDP: the game port players connect to. It is the default value of
endpoint_add_tcpandendpoint_add_udp, and both must use the same port. - 40120 TCP: the txAdmin web panel. Ports 40120 to 40150 are reserved for txAdmin and cannot be used as the game port.
- 3306: MariaDB. Do not open it to the internet if the database runs on the same VPS.
With ufw, allow SSH before enabling the firewall so you do not lock yourself out:
sudo ufw allow 22/tcp
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp
sudo ufw allow 40120/tcp
sudo ufw enable
sudo ufw status
For better security, allow txAdmin only from your IP: sudo ufw allow proto tcp from YOUR_IP to any port 40120. If you use an external firewall or anti-DDoS with allowlists, also allow the Cfx.re IPs listed in https://static.cfx.re/ips.txt, which the server browser uses to query your server.
To check that the port is reachable, open http://YOUR_IP:30120/info.json in a browser, or press F8 in FiveM and type connect YOUR_IP:30120.
How to set up the FiveM database with MariaDB and oxmysql
Frameworks such as ESX and QBCore store their data in a MySQL-compatible database through oxmysql. Its developers recommend MariaDB over MySQL 8, because many FiveM resources were written for MySQL 5.7 and can fail with MySQL 8 (more reserved words, no default values on longtext or JSON fields).
sudo apt install -y mariadb-server
sudo mariadb-secure-installation
sudo mariadb
On Debian and Ubuntu, MariaDB's root account authenticates through the system socket by default, so create a dedicated user for FiveM:
CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'a-strong-password';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;
EXIT;
When you deploy ESX or QBCore with a txAdmin recipe in the next step, the deployer asks for these details (host localhost, port 3306, user, password and database) and writes the configuration for you. If you configure it by hand, add this to server.cfg before any resource, with ensure oxmysql at the top of the resource list:
set mysql_connection_string "mysql://fivem:a-strong-password@localhost:3306/fivem"
ensure oxmysql
Use set, never setr or sets, so the password is not exposed. oxmysql advises avoiding the characters ; , / ? : @ & = + $ # in the connection string. If the console shows ECONNREFUSED, MariaDB is not running or is not listening on that address: check it with systemctl status mariadb.
Start txAdmin for the first time
Switch back to the fivem user with sudo -iu fivem and start the server:
cd ~/FXServer/server
./run.sh
Without +exec, FXServer starts txAdmin. The console shows the URL (http://your-public-ip:40120/) and a 4-digit PIN. Open it in your browser, link your Cfx.re account, create the backup password and deploy a recipe. txAdmin creates the txData folder next to run.sh, where it stores its configuration and, by default, the deployed server. Include that folder in your backups. Press Ctrl+C to stop the server; the next section explains how to keep it running. If you lose access to the panel, follow How to fix the txAdmin token, PIN and login errors.
How to keep the FiveM server running on Linux
Option 1: tmux (or screen, as the txAdmin docs suggest), as the fivem user:
tmux new -s fivem
cd ~/FXServer/server && ./run.sh
Detach with Ctrl+B and then D, and return with tmux attach -t fivem.
Option 2: systemd, which starts the server at boot. As your administrator user, create /etc/systemd/system/fivem.service:
[Unit]
Description=FiveM server (FXServer + txAdmin)
After=network-online.target mariadb.service
Wants=network-online.target
[Service]
User=fivem
WorkingDirectory=/home/fivem/FXServer/server
ExecStart=/home/fivem/FXServer/server/run.sh
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now fivem
sudo journalctl -u fivem -f
With systemd, the txAdmin URL and PIN appear in journalctl. txAdmin restarts FXServer if the game server crashes or freezes, and systemd restarts txAdmin if its process stops.
To run this on your own server, see the VPS for FiveM (Ryzen 9 7950X, full root, anti-DDoS, Frankfurt or Miami); if you prefer not to administer Linux, the managed FiveM server comes with txAdmin preinstalled and is managed from a panel.
Was this article helpful?
Need more help?
Open a ticket and the support team goes through it with you.