How to Run a FiveM Server on Ubuntu (Step-by-Step)

How to Run a FiveM Server on Ubuntu (Step-by-Step)

FiveM is one of the most popular GTA V multiplayer frameworks for custom servers. If you're running an Ubuntu VPS or dedicated server, you can deploy a FiveM server reliably with the following steps.

Need help hosting FiveM servers on high-performance hardware? EUGameHost offers ready-made and DDoS-protected game nodes for a smooth FiveM experience.

Get your FiveM Server - Starting from £4.80

Requirements

  • Ubuntu 20.04 or 22.04 (recommended)
  • Root SSH access or a sudo-enabled user
  • 2GB+ RAM (4GB+ recommended)
  • At least 5GB free disk space

1. Update Your Server

Start with updating your system:

sudo apt update && sudo apt upgrade -y

Install required packages:

sudo apt install git wget screen xz-utils -y

2. Create a New User (Optional)

It's best not to run the server as root:

sudo adduser fivem
sudo usermod -aG sudo fivem
su - fivem

3. Install FXServer (FiveM Server Binary)

Create a server folder:

mkdir -p ~/fivem_server && cd ~/fivem_server

Find the latest FXServer build here:

https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/

Find the latest build ID from that above page:

wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/9999-xxxxxx/fx.tar.xz
mkdir fxserver && tar -xvf fx.tar.xz -C fxserver

4. Install the FiveM Server Data

cd ~/fivem_server
git clone https://github.com/citizenfx/cfx-server-data.git server-data
cd server-data

Open server.cfg

nano server.cfg

Then paste in the following content:

# Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only.
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

# These resources will start by default.
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure basic-gamemode
ensure hardcap
ensure rconlog

# This allows players to use scripthook-based plugins such as the legacy Lambda Menu.
# Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won't be able to use external plugins.
sv_scriptHookAllowed 0

# Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like set rcon_password "YOURPASSWORD"
#set rcon_password ""

# A comma-separated list of tags for your server.
# For example:
# - sets tags "drifting, cars, racing"
# Or:
# - sets tags "roleplay, military, tanks"
sets tags "default"

# A valid locale identifier for your server's primary language.
# For example "en-US", "fr-CA", "nl-NL", "de-DE", "en-GB", "pt-BR"
sets locale "root-AQ" 
# please DO replace root-AQ on the line ABOVE with a real language! :)

# Set an optional server info and connecting banner image url.
# Size doesn't matter, any banner sized image will be fine.
#sets banner_detail "https://url.to/image.png"
#sets banner_connecting "https://url.to/image.png"

# Set your server's hostname. This is not usually shown anywhere in listings.
sv_hostname "FXServer, but unconfigured"

# Set your server's Project Name
sets sv_projectName "My FXServer Project"

# Set your server's Project Description
sets sv_projectDesc "Default FXServer requiring configuration"

# Set Game Build (https://docs.fivem.net/docs/server-manual/server-commands/#sv_enforcegamebuild-build)
#sv_enforceGameBuild 2802

# Nested configs!
#exec server_internal.cfg

# Loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png

# convars which can be used in scripts
set temp_convar "hey world!"

# Remove the `#` from the below line if you want your server to be listed as 'private' in the server browser.
# Do not edit it if you *do not* want your server listed as 'private'.
# Check the following url for more detailed information about this:
# https://docs.fivem.net/docs/server-manual/server-commands/#sv_master1-newvalue
#sv_master1 ""

# Add system admins
add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don't allow quit
add_principal identifier.fivem:1 group.admin # add the admin to the group

# enable OneSync (required for server-side state awareness)
set onesync on

# Server player slot limit (see https://fivem.net/server-hosting for limits)
sv_maxclients 48

# Steam Web API key, if you want to use Steam authentication (https://steamcommunity.com/dev/apikey)
# -> replace "" with the key
set steam_webApiKey ""

# License key for your server (https://portal.cfx.re)
sv_licenseKey changeme

Make sure you have a license key from https://keymaster.fivem.net


5. Run the Server

Navigate to your fxserver directory and launch:

cd ~/fivem_server/fxserver
./run.sh +exec ../server-data/server.cfg

Keep it running with screen or tmux:

screen -S fivem
./run.sh +exec ../server-data/server.cfg

(Detach with Ctrl+A then D)


6. Opening Ports (Firewall)

Make sure these ports are open:

  • UDP 30120 (main game port)
  • TCP 30120 (optional for some services)
  • TCP 40120 (TXAdmin Control Panel)

Example UFW config:

sudo ufw allow 30120/udp
sudo ufw allow 30120/tcp
sudo ufw allow 40120/tcp
sudo ufw enable

Make sure to also do this on your EUGameHost Edge Firewall Manager if you host with us.


7. Automatic Startup (Optional)

Create a systemd service file:

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

Paste:

[Unit]
Description=FiveM Server
After=network.target

[Service]
User=fivem
WorkingDirectory=/home/fivem/fivem_server/fxserver
ExecStart=/home/fivem/fivem_server/fxserver/run.sh +exec /home/fivem/fivem_server/server-data/server.cfg
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reexec
sudo systemctl enable --now fivem

Summary

You've now got a working FiveM server on Ubuntu with system-level startup, custom config, and properly open ports. Be sure to add mods, resources, and tweak your server.cfg to customize your experience.