Guide

How to Run a FiveM Server on Linux (Ubuntu/Debian)

Set up a FiveM server on Ubuntu or Debian: install xz-utils, download the artifact, extract it, run run.sh, keep it alive with tmux, and open the right ports.

sudo apt install -y xz-utils wget
mkdir -p ~/FXServer/server && cd ~/FXServer/server

You can run a FiveM server on Linux by installing xz-utils, downloading the recommended Linux artifact, extracting it and starting run.sh. The official setup guide follows these steps. Ports and a firewall are needed before players can join.

Note

The official docs describe the Linux build as a courtesy port, and recommend Windows if you need the most reliable support. Linux works for many servers, but expect fewer answers when something breaks.

Last checked: 11 September 2026

What do I need before I start?

  • A 64-bit Linux machine. The commands here are for Ubuntu or Debian.
  • A non-root user to run the server. Running a game server as root means scripts run as root too.
  • The xz package, which the docs call xz-utils on Debian and Ubuntu.
  • Git, if you want to clone the official cfx-server-data repository.
  • A license key. The vanilla docs put it in server.cfg as sv_licenseKey.

Create the user first, then switch to it with su - fivem before the next steps:

sudo adduser fivem

How do I download and extract the server?

On the Server Download page on docs.fivem.net, copy the link of the recommended master Linux build. Then run:

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

The docs name the archive fx.tar.xz. The -O flag keeps that name even if the download link is different. Build links change, so always copy the current one from the download page. After extraction, run ls ~/FXServer/server and confirm that run.sh is in the list. If it is not, the archive went to a different folder than you expected, and bash run.sh will fail with a missing file error. Fix the path before you go further.

How do I start it?

The vanilla setup clones the server data and starts from its folder:

git clone https://github.com/citizenfx/cfx-server-data.git ~/FXServer/server-data
cd ~/FXServer/server-data
bash ~/FXServer/server/run.sh +exec server.cfg

The +exec server.cfg part loads your config file. If you use txAdmin, which many servers do, the panel takes over the setup, and community guides suggest starting without +exec. That is not in the vanilla docs, so follow the txAdmin login steps in txAdmin login and port fixes. Then check the console for the panel address. If the console reports a missing license key, the cause is usually the folder you ran the command from, or a server.cfg that is not in server-data. Check those before you reinstall anything.

How do I keep it running after I close SSH?

A terminal multiplexer keeps the server alive when your SSH session ends:

sudo apt install -y tmux
tmux new -s fivem
cd ~/FXServer/server-data && bash ~/FXServer/server/run.sh +exec server.cfg

Detach with Ctrl+B and then D. Come back later with tmux attach -t fivem. screen works the same way. A multiplexer survives a closed SSH session, but it does not start the server after a reboot. For that, use a service.

How do I run it as a systemd service?

This unit is an example, not an official file. Adjust the user and paths, then test it:

[Unit]
Description=FiveM server
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=fivem
WorkingDirectory=/home/fivem/FXServer/server-data
ExecStart=/bin/bash /home/fivem/FXServer/server/run.sh +exec server.cfg
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

Save it as /etc/systemd/system/fivem.service. Then run sudo systemctl daemon-reload, sudo systemctl enable --now fivem and journalctl -u fivem -f. If you use txAdmin, it can restart the server itself, so watch the journal for restart loops.

Which firewall ports do I open?

The vanilla docs configure the game server on port 30120 for both TCP and UDP, bound to 0.0.0.0. txAdmin uses TCP 40120 by default, which should stay private.

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

Allow SSH first, or you can lock yourself out. After you change rules, test from outside your network, for example from a phone on mobile data. A test from the server itself can pass while outside traffic is still blocked. Some hosts also run a firewall in their panel, outside the operating system, so check that too. Once the server is up, check it on the server list. If it is missing, read server not showing in the server list. For attacks, read FiveM DDoS protection.

Is the Enhanced build different?

Yes, in the download file name. If you run both builds on one machine, keep each in its own folder so the archives do not overwrite each other. The docs say the GTA V Enhanced archive is cfx-server-linux_x64, not fx.tar.xz. Extract it the same way, and follow the Enhanced notes on the same docs page. I did not check the file layout inside the archive, so confirm it there. For the legacy and Enhanced difference, see Legacy vs Enhanced.

Before you start the service, run the server once by hand as the fivem user. If it works in the terminal but not as a service, the usual causes are a wrong path in ExecStart or a file owned by another user. Read the journal with journalctl -u fivem -n 100 rather than guessing.

What usually doesn't help

Community-reported: running the server as root, or reinstalling the artifact when the real problem is a missing license key or a wrong folder. The docs' own troubleshooting note is that a missing license key message or resources that never start usually means you ran commands from the wrong folder or left out +exec. Check those first.

Another common mistake is opening the game port but not the TCP and UDP pair. Players need both.

If nothing works

Collect these details before you ask for help:

  • Your distribution and version, from cat /etc/os-release.
  • The artifact build number you downloaded.
  • The full boot output from the console.
  • The listening ports, from ss -tulpn | grep -E "30120|40120".
  • Your firewall rules, with any IP addresses removed.

Post them on forum.cfx.re. Do not post your license key or your txAdmin password.

Frequently asked questions

Can you run a FiveM server on Linux?

Yes. The official docs describe the Linux build as a courtesy port, so Windows gets more attention for bugs.

How do I install a FiveM server on Ubuntu?

Install xz-utils, download the recommended Linux build from the Server Download page, extract fx.tar.xz, clone cfx-server-data, and start it with run.sh and +exec server.cfg.

Which ports does a FiveM server need?

Port 30120 over both TCP and UDP for players. If you use txAdmin, keep TCP 40120 limited to your own IP.

Where should the server data live?

The vanilla docs clone cfx-server-data into ~/FXServer/server-data, separate from the binaries in ~/FXServer/server. Keeping them apart means you can update the artifact without touching your config or your resources.

How do I keep the server running after I log out?

Use tmux or screen for a quick setup, or a systemd service if the server should start after a reboot.

What is the Linux file name for GTA V Enhanced?

The docs name it cfx-server-linux_x64. The standard build is fx.tar.xz.

FiveM.tools was founded with sponsorship from Nyru.