Auf dieser Seite
FiveM runs very well on Linux: it uses less RAM than Windows (no desktop to run) and the server restarts quickly. In this guide you install a FiveM server on Ubuntu 22.04 or 24.04, manage it with txAdmin and keep it online 24/7.
What you need
- An Ubuntu VPS — for up to 32 players about 4 vCores and 8–12 GB RAM, for 64 players 6 vCores and 16 GB (see How much RAM does a FiveM server need?).
- A free FiveM license key from portal.cfx.re.
- Your server IP and root password (or SSH key) from your ServerLoom dashboard.
- About 30 minutes.
Step 1: Connect with SSH
On Windows open PowerShell, on Mac or Linux open Terminal, and type (use the username from your dashboard if it is not root):
ssh root@YOUR-SERVER-IP
Step 2: Update the server and open the ports
FiveM needs port 30120 (TCP and UDP) for players and 40120 (TCP) for txAdmin. Always allow SSH first, or the firewall locks you out:
apt update && apt upgrade -yapt install -y xz-utils tmux wget ufw allow OpenSSHufw allow 30120/tcpufw allow 30120/udpufw allow 40120/tcpufw enable
Step 3: Create a user for FiveM
Never run a game server as root: if a script is ever hacked, the attacker only gets this user, not your whole server.
adduser --disabled-password --gecos "" fivemsu - fivemmkdir -p ~/server ~/server-data
Step 4: Download the FiveM Linux server
Open the FiveM Linux artifacts page in your browser, right-click the build marked LATEST RECOMMENDED and copy the link of fx.tar.xz. Then paste it after wget:
cd ~/serverwget -O fx.tar.xz "PASTE-THE-LINK-HERE"tar xf fx.tar.xzrm fx.tar.xz
Step 5: Start txAdmin inside tmux
tmux keeps the server running after you close your SSH window.
tmux new -s fivemcd ~/server && ./run.sh
The console shows a 4-digit PIN. Open http://YOUR-SERVER-IP:40120 on your PC, enter the PIN, log in with your Cfx.re account and choose a backup password.
To leave the console without stopping the server press Ctrl + B, then D. To come back later: su - fivem and then tmux attach -t fivem.
Step 6: Add a database (QBCore / ESX)
Roleplay frameworks store players, money and inventories in MariaDB. Open a second SSH window as root and run:
apt install -y mariadb-servermysql_secure_installation mysql -e "CREATE DATABASE fivem; CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'CHOOSE-A-STRONG-PASSWORD'; GRANT ALL PRIVILEGES ON fivem.* TO 'fivem'@'localhost'; FLUSH PRIVILEGES;"
Never open port 3306 in the firewall. Your database only needs to be reached from the server itself (127.0.0.1).
Step 7: Deploy your city
- In txAdmin choose Popular Recipes, then QBCore, ESX or CFX Default (not sure? read ESX vs QBCore vs Qbox).
- Data location: /home/fivem/server-data.
- Paste your license key from portal.cfx.re.
- Database: host 127.0.0.1, port 3306, user fivem, your password, database fivem.
- Click Run Recipe, then Save & Run Server. Players join with connect YOUR-SERVER-IP:30120 in the F8 console.
Step 8: Start automatically after a reboot
As the fivem user, open the crontab with crontab -e and add this line at the end:
@reboot cd /home/fivem/server && /usr/bin/tmux new-session -d -s fivem ./run.sh
Troubleshooting
- ./run.sh: Permission denied — run chmod +x run.sh in the server folder.
- txAdmin does not open — check the 40120 rule with ufw status, and see txAdmin localhost:40120 fixes.
- Players time out while joining — UDP 30120 is missing, or your license key is wrong.
- Server lags with free RAM left — FiveM needs a fast CPU more than many cores; a high-clock Ryzen helps most.
Next step: protect your FiveM server from DDoS attacks and secure your Linux VPS.
Dauerhafter ServerLoom Shield, hochgetaktete Ryzen und ein Team, das FiveM kennt — rund um die Uhr online.