TürkiyeVPS

How to Set Up a FiveM Server: Step by Step with txAdmin on a Linux VPS (Ubuntu 24.04)

Set up your own GTA V roleplay server on Linux: downloading the FiveM server files, first-time setup with txAdmin, the Cfx.re license key, a MariaDB database, firewall ports, a systemd service and backups. Step by step on Ubuntu 24.04.

7 min read

FiveM is a multiplayer platform built for GTA V, and in Turkey it is especially popular for its roleplay (RP) servers. When you run your own FiveM server, you decide everything, from the map and vehicles to jobs and the economy. You can host a server on your home computer, but when the computer shuts down the server goes down with it, and your home upload speed limits how many players you can have. A Linux VPS or VDS, on the other hand, stays online day and night and comes with a static IP address.

In this guide we'll set up a FiveM server on Ubuntu 24.04 with txAdmin. txAdmin is a web-based management panel bundled with the FiveM server files; it makes it easy to start and stop the server, manage players, take backups, and install frameworks such as ESX or QBCore using ready-made "recipes".

Before you start: you need a Cfx.re account and a server license key that you create at portal.cfx.re. The key is free; just sign in with your account and generate a key for your server. You must comply with the terms of service of FiveM and Rockstar Games.

How many resources do you need?

A server's requirements vary widely depending on the framework you install and the number of resources. Roughly:

  • Empty or lightweight server, few players: 2 vCPU, 4 GB RAM.
  • Mid-sized ESX/QBCore-based RP server: 2-4 vCPU, 8 GB RAM.
  • Many resources and a crowded player base: more RAM and high single-core performance.

FiveM servers use the CPU constantly and are sensitive to latency. That's why a server with a CPU dedicated to you gives more stable results than a VPS with shared CPU. Choose NVMe storage; database queries and resource loading become faster.

1. Prepare the server

Connect to your server over SSH and update the system:

sudo apt update && sudo apt upgrade -y
sudo apt install -y xz-utils wget tmux

Running the FiveM server as root is not safe. Create a separate user:

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

2. Install the database (for ESX/QBCore)

Frameworks such as ESX and QBCore store player data in a MySQL/MariaDB database. If you're setting up an empty server, you can skip this step.

sudo apt install -y mariadb-server
sudo mariadb

At the MariaDB prompt that opens, create a database and a user. Replace the password with your own strong one:

CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'GucluBirSifre123!';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;
EXIT;

By default MariaDB only accepts connections from the server itself (localhost); there's no need to expose it to the outside.

3. Download the FiveM server files

FiveM's Linux server files (artifacts) are published at https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/. Open the page in your browser, right-click the LATEST RECOMMENDED button and copy the link. The link ends with fx.tar.xz and contains a version number.

Now switch to the fivem user and download the files. In the command below, replace the address in quotes (KOPYALADIGINIZ_BAGLANTI) with the link you copied:

sudo -iu fivem
mkdir -p ~/server && cd ~/server
wget -O fx.tar.xz "KOPYALADIGINIZ_BAGLANTI"
tar xf fx.tar.xz
rm fx.tar.xz

The folder should now contain a run.sh file and an alpine folder. Type exit to return to your own user.

4. Configure the firewall

FiveM uses port 30120 over both TCP and UDP for player connections. The txAdmin panel runs on port 40120/TCP by default. Rather than opening the panel to everyone, it's safer to open it only to your own IP address:

sudo ufw allow OpenSSH
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp
sudo ufw allow from SIZIN_IP_ADRESINIZ to any port 40120 proto tcp
sudo ufw enable

If your home IP address changes, you can temporarily open the txAdmin port to everyone (sudo ufw allow 40120/tcp) and close it after setup. For more on UFW, see our article on server management commands.

5. First-time setup with txAdmin

Let's do the first run in a tmux session so the server keeps running even if your SSH connection drops:

sudo -iu fivem
tmux new -s fivem
cd ~/server && ./run.sh

After a few seconds, the terminal shows the txAdmin address and a four-digit PIN. Open http://SUNUCU_IP:40120 in your browser and:

  1. Enter the PIN, sign in with your Cfx.re account and set an admin password.
  2. Give your server a name in the setup wizard.
  3. Pick a framework from the Popular Recipes section. For an empty server you can choose "CFX Default"; for RP, pick one of the ESX or QBCore recipes.
  4. Enter your license key. If you chose ESX or QBCore, in the database step enter the fivem user and password you created in step 2 and fivem as the database name.
  5. When the recipe has finished installing, start the server with Save & Run Server.

To leave the tmux session, press and release Ctrl+B, then press D. The server keeps running in the background. To return, type tmux attach -t fivem.

To join the game, open the console in the FiveM client with F8 and type connect SUNUCU_IP:30120.

6. Make it permanent with a systemd service

tmux is fine for testing, but if you want FiveM to start automatically when the server reboots, create a systemd service. First stop the server in tmux (tmux attach -t fivem, then Ctrl+C), then, as your own user:

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

Put the following in the file:

[Unit]
Description=FiveM sunucusu (txAdmin)
After=network-online.target mariadb.service
Wants=network-online.target

[Service]
User=fivem
WorkingDirectory=/home/fivem/server
ExecStart=/home/fivem/server/run.sh
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable --now fivem
sudo systemctl status fivem

You can follow the logs with sudo journalctl -u fivem -f. From now on you can manage the server from the txAdmin panel.

7. Backups and updates

txAdmin keeps server data and settings in the txData folder, while the database lives in MariaDB. Back up both regularly:

sudo mariadb-dump fivem > /root/fivem-db-$(date +%F).sql
sudo tar czf /root/fivem-files-$(date +%F).tar.gz -C /home/fivem server/txData

Don't keep backups only on the same server; copy them elsewhere with rsync. To update the server files, stop FiveM, download the new artifact as in step 3, extract it into the same folder and restart the service. Always take a backup before updating.

Common mistakes

  • Using "leaked" resources: Unauthorized copies of paid resources often contain backdoors and can lead to your server being compromised. Only get resources from trusted sources.
  • Leaving the txAdmin port open to everyone: The panel gives full control over your server. Use a strong password and, if possible, open the port only to your own IP.
  • Running as root: A vulnerability in a single resource puts the whole server at risk. Use a separate user.

To secure your server in general, also follow the steps in our Linux server security guide.

TürkiyeVPS game servers for FiveM

Our game server plans come with dedicated vCPUs on an Intel Core i5-10400F, guaranteed RAM and 1 dedicated IPv4 address; since you get root access, you can apply the setup in this guide directly. For a mid-sized RP server, plans with 8 GB RAM are a good starting point. The servers are in Istanbul, so latency is low for players in Turkey. We explain the impact of location in our article on Turkey-located VPS.

Frequently Asked Questions

Does it cost money to set up a FiveM server?

The FiveM server software and the standard license key are free. Your costs are the server rental and any paid resources you want to use. The player limit and extra features depend on your license type; check the current terms on the Cfx.re portal.

How much RAM does a FiveM server need?

A lightweight server runs on 4 GB of RAM. For an ESX- or QBCore-based RP server with many resources, 8 GB or more is recommended. Decide by monitoring usage in the txAdmin panel and with htop.

Should a FiveM server run on Windows or Linux?

Both are supported. Linux servers use fewer resources and are well suited to running continuously for long periods. The steps in this guide are for Ubuntu 24.04.

What should I do if players can't connect to the server?

First check with sudo ufw status that ports 30120 TCP and UDP are open. Then look for a license key error in the txAdmin console. Make sure the key shows as valid on the portal and was created with the correct server details.