Press Enter to search

How to Install a FiveM Server on Linux (Debian and Ubuntu)

Linux guide

How to Install a FiveM Server on Linux (Debian and Ubuntu)

To install a FiveM server on Debian or Ubuntu, create a normal user, download the latest recommended Linux build (fx.tar.xz) from the official artifacts page, extract it, and start run.sh. That starts txAdmin on port 40120, where you deploy a recipe. Then open port 30120 on TCP and UDP and run the server as a systemd service. Or run one command with the FiveMRides installer that does all of this.

By FiveMRides. Last updated: November 2026.

Quick answer
  • System: a fresh Debian 12 or 13, or Ubuntu 22.04 and newer, with root access.
  • Packages: xz-utils, wget, git, MariaDB, ufw.
  • Files: the official Linux build, extracted to ~/FXServer/server.
  • Start: ./run.sh without +exec server.cfg opens txAdmin.
  • Ports: 30120 TCP and UDP for players. Keep 40120 and SSH restricted.

Official note: the FiveM documentation says the Linux version of the server is a courtesy port and that issues are more likely to be fixed on Windows. It works well for many communities, and you should know that going in. See Windows vs Linux.

Step 1: prepare the system

Log in as root over SSH and update the system. A minimal Debian has neither curl nor sudo, so install what you need.

apt-get update && apt-get upgrade -y
apt-get install -y curl wget git xz-utils screen ufw mariadb-server

Create a normal user that runs the game server. Never run FiveM as root.

adduser --disabled-password --gecos "" fivem
su - fivem

Step 2: download the server files (artifacts)

Open the official server download page or the Linux artifacts index at runtime.fivem.net/artifacts/fivem/build_proot_linux/master/ and copy the link of the recommended build. Do not guess a build number.

mkdir -p ~/FXServer/server
cd ~/FXServer/server
wget "PASTE_THE_BUILD_LINK_HERE" -O fx.tar.xz
tar xf fx.tar.xz

For the GTA V Enhanced edition, the official page names the file cfx-server-linux_x64. Use the matching build, and follow the page for that edition.

The official guide also clones the base server data. If you use a txAdmin recipe you do not need it, because the recipe downloads its own.

Step 3: create the database

Framework servers (QBCore, ESX) need MariaDB or MySQL. Create a dedicated database and user, as root:

mariadb -e "CREATE DATABASE fivem CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'CHANGE_THIS_PASSWORD';
GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;"

The connection string for the common oxmysql resource looks like this in server.cfg (recipes usually write it for you):

set mysql_connection_string "mysql://fivem:CHANGE_THIS_PASSWORD@localhost/fivem?charset=utf8mb4"

Keep MariaDB listening on localhost only. A default MariaDB install on Debian does this.

Step 4: open the firewall

ufw allow 22/tcp
ufw allow 30120/tcp
ufw allow 30120/udp
# txAdmin: allow only your own address (documentation address shown)
ufw allow from 203.0.113.50 to any port 40120 proto tcp
ufw enable

Make sure the SSH rule is in before you enable ufw. Your host may also have a firewall in its dashboard; open the same ports there.

Step 5: start txAdmin

As the fivem user:

cd ~/FXServer/server
screen -S fivem
./run.sh

Without +exec server.cfg, FiveM starts txAdmin and creates a txData folder. The console prints the address, normally http://YOUR_SERVER_IP:40120, and a one-time PIN for the first setup. Open it in a browser, log in with your Cfx.re account and run the deployer. The txAdmin on Linux guide goes through the screens, recipes and errors. Detach from screen with Ctrl+A then D.

Step 6: run it as a service

A screen session ends when the machine reboots. A systemd service restarts the server automatically. Create /etc/systemd/system/fivem.service as root:

[Unit]
Description=FiveM server (txAdmin)
After=network.target mariadb.service

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

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now fivem
journalctl -u fivem -f

Stop the screen copy first so two servers do not fight over the ports. We have not tuned this unit file for every distribution; if txAdmin restarts the server from its own menu, check the logs with journalctl.

Step 7: license key and connect

Enter your license key from the Cfx.re Portal in the txAdmin setup, or set sv_licenseKey in server.cfg. Then connect from the FiveM client with connect 203.0.113.10:30120 using your own address.

Updates, backups and hardening

  • Artifacts: by default txData sits in the folder that holds run.sh, so a new build in a new folder starts with an empty txAdmin. Before you switch folders, set TXHOST_DATA_PATH to a fixed folder (see the txAdmin guide), then download the newer build into a new folder, keep the old one for rollback, and change the service path.
  • Backups: back up the database (mariadb-dump), your resources folder and txData. Test a restore.
  • Security: SSH keys only, keep 40120 restricted, read the DDoS protection guide.
  • Specs: see the VPS sizing guideline.
Our recommended hostStill need a Linux VPS? Contabo

A Contabo Performance VPS gives you plenty of RAM for scripts, maps and cars, recent AMD EPYC CPUs with NVMe storage, always-on DDoS protection included, and monthly terms. Pick the location closest to your players.

See Contabo VPS plans Why we pick Contabo

Contabo is our hosting partner: we may earn a commission at no extra cost to you.

Sponsored
Contabo VPS

The one-command alternative

Everything above, plus nginx with a free Let’s Encrypt certificate if you give it a domain, tuned MariaDB, automatic artifact updates, scheduled backups and a web panel, is done by the FiveMRides installer. On a fresh Debian 12 or 13 (or Ubuntu 22.04 and newer) server as root:

apt-get update && apt-get install -y curl && bash <(curl -fsSL https://fivemrides.com/installer/setup.sh)

It asks for a FiveMRides Server Panel license key before it starts, and it is tested on Debian 12 and 13 on our own machines.

Skip the manual work

The FiveMRides Server Panel installs a FiveM server on your own Linux VPS with one command, then gives you a web panel for updates, backups and protection. One lifetime license, and it is also included with Studio Max and Unlimited. FiveMRides is independent software and is not affiliated with Cfx.re or Rockstar Games.

Questions about installing FiveM on Linux

Which Linux is best for a FiveM server?

Debian 12 or 13 or Ubuntu 22.04 and newer are the common choices. The FiveMRides installer is tested on Debian 12 and 13.

Where do I download the FiveM Linux server files?

From the official Cfx.re server download page or the artifacts index at runtime.fivem.net. Copy the recommended build link and download it as fx.tar.xz.

How do I start a FiveM server on Linux?

Run ./run.sh from the extracted server folder. Without +exec server.cfg it starts txAdmin; with +exec server.cfg it starts the server directly from the data folder.

Why does my FiveM server stop when I close SSH?

It was started in a normal session. Use screen or, better, a systemd service so it keeps running and restarts after a reboot.

Which ports does FiveM use on Linux?

30120 on TCP and UDP for players, and 40120 for txAdmin by default.

Can I run FiveM as root?

You should not. Create a normal user so a bug in a resource has less power over the machine.

Is the manual install worth it compared with the installer?

Doing it once teaches you how it works. The installer saves time and repeats the same setup on each new server, and adds updates, backups and a panel.

GET 35% OFF YOUR FIRST RIDE

Join the FiveMRides list for new drops, free tools and subscriber-only deals. Your 35% code arrives right after you sign up.

We do not spam! Read our privacy policy for more info.

Scroll to Top