How to set up a FiveM server from scratch on Ubuntu Linux
Technical guide to running a FiveM server on an Ubuntu 24.04 VPS: download artifacts, configure server.cfg, generate a license key and open UFW ports.
Running a FiveM server on Linux is cheaper in resources than on Windows and gains stability on long uptimes, but it requires understanding a few platform-specific details: the official artifacts ship as a tarball, CFX requires a license key tied to the IP, and the default port must be open on TCP and UDP — forgetting one of the two is the number one cause of “server does not show up in the list”.
This tutorial covers a from-scratch install on an Ubuntu 24.04 LTS VPS, from the dedicated user up to the server accepting connections. The persona is a new server owner migrating away from a managed host to a Linux VPS who needs to understand what each piece does.
Estimated time: 20 to 30 minutes on a reasonable VPS, including artifact download.
Prerequisites
You need an Ubuntu 24.04 LTS VPS with sudo access, at least 2 GB of RAM and ~5 GB of free disk space. A working SSH connection and the public IP of the VPS at hand (you will need it to generate the license key).
Before starting, write down the access details you will use throughout the tutorial. On a freshly provisioned Hostini VPS, they arrive in the welcome email:
Ubuntu 24.04 LTS SSH as root or sudo 30120 (TCP+UDP) recommended Confirm the system version before proceeding:
lsb_release -a
The output should show Description: Ubuntu 24.04 LTS or similar. If you are on an older release (20.04, 22.04), the tutorial still works — only the package commands may vary slightly.
Create a dedicated user for the server
Running FiveM as root is unsafe: any flaw in a poorly written resource becomes full administrative access to the machine. Creating a separate user takes 30 seconds and isolates the blast radius.
Create the fivem user with the default home directory:
sudo adduser --disabled-password --gecos "" fivemThe --disabled-password flag prevents direct password login (you access it via sudo su - fivem from your sudo user). This reduces the SSH brute-force attack surface on the server account.
Switch to the newly created user:
sudo su - fivemFrom here on, every command involving server files runs inside this session. You are in /home/fivem.
Install system dependencies
FiveM on Linux requires a few system libraries that are not installed by default on Ubuntu Server. Missing any of them results in a generic “segmentation fault” error at startup, which is hard to diagnose.
Exit back to the sudo user (exit) and refresh the package index:
sudo apt update
sudo apt install -y xz-utils curl screen libssl3 ca-certificatesxz-utils extracts the artifacts tarball (format .tar.xz), screen keeps the server running after you disconnect from SSH, and libssl3 is the TLS runtime that FiveM links dynamically.
For a production server, systemd is superior to screen — it restarts on crash, integrates with journalctl and survives host reboots. The “Next steps” section points to how to migrate once you confirm the server boots correctly.
Download the official artifacts
CFX publishes Linux server builds at runtime.fivem.net. Each build has a unique hash and is incremental. For production, always use the recommended branch.
Switch back to the fivem user and create the folder layout:
sudo su - fivem
mkdir -p ~/server ~/server-data
cd ~/serverSplitting server/ (artifacts) from server-data/ (your configuration and resources) makes upgrades easier: you download new artifacts replacing server/ without touching your data.
Download the latest tarball from the recommended branch. The link changes with every build — always check https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/ in the browser to grab the current version. Replace the URL below with the current one:
curl -sLo fx.tar.xz https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/15601-COMMIT_HASH/fx.tar.xz
tar xf fx.tar.xz
rm fx.tar.xzAfter extraction, you will have the run.sh binary and the alpine/ and opt/ folders inside ~/server/.
Builds older than 6 months usually cannot connect to the CFX master list anymore because the licensing endpoints have changed. If you are bringing back a server that has been stopped for a long time, download a fresh build before trying to diagnose connection issues.
Generate the license key
Since 2018 CFX has required a license key for any server — without it the server boots but rejects every connection with an authentication error. The key is free and tied to the machine’s public IP.
In a browser, go to keymaster.fivem.net, log in with your CFX account and create a new key. The panel asks for:
- IP address: the public IP of your VPS (the same one you SSH to)
- Server type: VPS / Dedicated
The generated key has the format xxxxxxxxxxxxxxxxxxxx. Copy it and keep it safe.
If your VPS IP changes (migration, new provider, plan swap), the existing key stops working. Go back to keymaster and update the IP — you do not need to generate a new one, just edit the existing key. Hostini servers come with a static IP, so this is only an issue if you migrate.
Configure server.cfg
The server.cfg file defines the name, slot count, license key, loaded resources and ports. We will start from the official template and adjust only the minimum required for the server to boot.
Initialize server-data/ from the official template via git:
cd ~/server-data
git clone https://github.com/citizenfx/cfx-server-data.git .This brings in a sample server.cfg and the resources/ folder with the basic resources (mapmanager, chat, spawnmanager). Enough for the first boot.
Edit server.cfg:
nano server.cfgFind the sv_licenseKey changeme line and replace changeme with the key generated at keymaster. Also adjust:
sv_hostname "My FiveM Server"
sv_maxclients 32
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"0.0.0.0 makes the server listen on every network interface. Use 127.0.0.1 only if you plan to put a reverse proxy in front.
Open the firewall ports
Ubuntu 24.04 ships with ufw installed but inactive. Before enabling the firewall, allow SSH so you do not lock yourself out, then open the FiveM port.
Allow the required ports:
sudo ufw allow OpenSSH
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp
sudo ufw enableConfirm with sudo ufw status — you should see all three rules active.
If you forget the allow OpenSSH rule and enable the firewall over an SSH session, you lose access immediately. Always confirm the SSH rule before running ufw enable. If you do lock yourself out, you will need the VPS web console to fix it.
Boot the server
With the config ready and the firewall open, it is time for the first boot.
Switch back to the fivem user and start the server inside a screen so it keeps running after you disconnect:
sudo su - fivem
screen -S fivem
cd ~/server-data
bash ~/server/run.sh +exec server.cfgYou will see the server log scroll. Successful logs include Authenticating server license key... followed by Server license key authenticated. After that, Server started, ready for connections.
To detach from screen without killing the process, press Ctrl+A followed by D. To reattach later: screen -r fivem.
Verification
Confirm that the server is responding on the port and reachable externally.
From the VPS itself, test locally:
curl -s http://localhost:30120/info.json
The response should be a JSON containing vars, enhancedHostSupport and resources. If it comes back empty or returns Connection refused, the server has not finished booting or has crashed — go back to the screen and check the log.
From another machine, open the FiveM client and connect by direct IP:
YOUR_VPS_IP:30120
If it connects, the server is operational and visible to CFX. Within 5 minutes or so it also appears in the public list when filtered by name.
Troubleshooting
Server boots but does not appear in the public list
Almost always it is blocked UDP. Confirm with sudo ufw status that the 30120/udp rule is active. On some providers there is an edge firewall in addition to the host’s UFW — check the provider panel.
Error “Server license key invalid”
The key is tied to an IP different from the current one. Go to keymaster, edit the existing key and update the IP to the VPS one.
Server gets killed after a few minutes
Out of RAM. Run free -h and check if swap is exhausted. Vanilla FiveM needs at least 2 GB free; with a roleplay framework, plan on 8 GB.
Next steps
With the base server operational, consider:
- Migrate from
screentosystemd: creates a service unit that restarts the server after a crash and survives host reboots. - Set up automated backups of
server-data/to external storage — losing the framework’s database is expensive. - Install a framework (ESX, QBCore, vRP) on top of the vanilla server, depending on the type of gameplay.
- Add a reverse proxy with nginx or caddy to serve the server’s status panel over HTTPS.
- Monitor CPU and RAM with basic tools like
htopor a dedicated metrics agent.
If you are putting this into production, it is worth considering a VPS optimized for game servers — machines with high single-thread CPU clocks, a static IP and protection against saturation attacks, which is the typical weak point of FiveM servers exposed to the internet.
Frequently asked questions
What is the difference between the recommended and latest artifacts?
The `latest` branch ships fixes earlier but may introduce regressions. The `recommended` branch is validated by CFX after a few days in testing and is the default choice for production servers. Only use `latest` if you need a specific fix or are testing new features.
Why does my server appear offline even though it is running?
Almost always it is a firewall blocking UDP 30120. FiveM uses TCP for the status HTTP endpoint and UDP for game traffic — if UDP does not get through, the server will not show up in the CFX list and will not accept connections. Confirm with `sudo ufw status` and open both ports.
Do I need a license key even for a private test server?
Yes. Since 2018 CFX has required a license key for any server — including localhost. The key is free, generated at keymaster.fivem.net and tied to the server IP. Without it the server boots but rejects connections with an authentication error.
How much RAM does a basic FiveM server consume?
A vanilla server with 32 slots and few resources consumes between 1.5 and 3 GB of RAM. Roleplay servers with a framework (ESX/QBCore) and 64 slots easily go past 6 GB. For serious projects, plan on 8 GB as a floor and a CPU with good single-thread performance, since FiveM is mostly single-threaded.
Can I run the server as root?
You can, but you should not. Running exposed network services as root is unsafe — any exploit in FiveM or in poorly written resources becomes full-privilege RCE. Create a dedicated user (`adduser fivem`) and run everything from that account.
Does the server restart on its own if the VPS reboots?
No, unless you configure it. For real resilience use `systemd` with a dedicated service unit or `tmux`/`screen` with autostart in `crontab @reboot`. Without that, any host reboot will drop the server until manual intervention.