Set up a FiveM server
Your own GTA V roleplay or freeroam server with FiveM: get a license key, understand server.cfg, add resources and configure OneSync. The base installation with a txAdmin recipe is covered in the txAdmin guide – this one is about what comes next.
8 min read · Last reviewed: October 2026
Requirements
- A Cfx.re account (same login as the FiveM forum)
- A server running FXServer – rented or self-hosted (Linux or Windows)
- For frameworks such as ESX or QBCore: a MySQL/MariaDB database
- Basic experience editing text files
Step 1: Create a license key
Every FiveM server needs its own license key. It's free and is created in the Cfx.re portal – the old address keymaster.fivem.net now redirects there.
- Log in to portal.cfx.re with your Cfx.re account.
- Create a new key in the server license keys section.
- Enter your server's public IP and a name.
- Copy the key and treat it like a password.
At AvantaHost you enter the key when ordering. If you don't have it yet, you can submit it later in the dashboard on the order – the server is set up right after. In the server panel it's the startup variable FIVEM_LICENSE in the Startup tab („Start“), where you can also replace it. Changes apply on the next start.
server.cfg containing the key to GitHub.Step 2: Understand server.cfg
server.cfg is the central configuration. It lives in the server data folder next to the resources folder. A lean baseline looks like this:
# Network: player port (TCP and UDP) endpoint_add_tcp "0.0.0.0:30120" endpoint_add_udp "0.0.0.0:30120" # Default resources ensure mapmanager ensure chat ensure spawnmanager ensure sessionmanager ensure basic-gamemode ensure hardcap # Server list display sv_hostname "My FiveM Server" sets sv_projectName "My Project" sets sv_projectDesc "A short description of your server" sets tags "roleplay, english" sets locale "en-US" # Slots (up to 48 without a subscription) sv_maxclients 48 # Steam Web API key, if resources need Steam IDs set steam_webApiKey "" # License key sv_licenseKey "YOUR_KEY"
- endpoint_add_tcp/udp: port 30120 is the default. On rented servers this has to be the port you were assigned – at AvantaHost the primary allocation in the Network tab. Don't change it on your own.
- sv_maxclients: FiveM is free up to 48 slots. More needs a subscription in the Cfx.re portal (from “Element Club Argentum”). More than 32 slots require OneSync.
- sets locale: templates often ship with
root-AQ– replace it with a real locale such asen-US. - sv_licenseKey: hosts with a startup variable often set this automatically. If you see a placeholder there, don't overwrite it by hand as long as the server starts.
In the AvantaHost panel you edit the file in the browser in the Files tab. With txAdmin running you can also use the CFG Editor in the txAdmin menu.
Step 3: Install resources
Everything your server does – jobs, cars, maps, menus – is a resource: a folder containing an fxmanifest.lua.
- Download the resource (preferably from GitHub or the Cfx.re forum) and extract it.
- Upload the folder to
resources/. Folders in square brackets such as[cars]are categories and may contain further resources. - Make sure
fxmanifest.luasits directly inside the resource folder – not one level deeper (a classic mistake with GitHub ZIPs containing folders likename-main/name/). - Add a line
ensure resourcenametoserver.cfg. The name is the folder name. - Restart the server.
# Dependencies first ensure oxmysql ensure ox_lib # then framework and scripts ensure [core] ensure [standalone]
For testing without a restart there are console commands: refresh rescans the resources folder, ensure name starts or restarts a resource, stop name stops it. For permanent use, the ensure line still belongs in server.cfg.
Step 4: Connect a database (ESX, QBCore)
Frameworks such as ESX Legacy and QBCore store players, inventories and vehicles in MySQL/MariaDB. The connection almost always runs through oxmysql.
In the AvantaHost panel you create the database in the Databases tab, which shows host, user and password. Then add this to server.cfg, before ensure oxmysql:
set mysql_connection_string "mysql://USER:PASSWORD@HOST:3306/DATABASE?charset=utf8mb4"
Frameworks don't always create their tables themselves. Usually there's a .sql file to import once. If you deploy the server with a txAdmin recipe, the deployer asks for the database details and runs the import.
Step 5: Configure OneSync
OneSync is FiveM's server-side synchronisation. Without it, clients talk to each other peer-to-peer; with it, the server knows the state of every player and vehicle. Modern frameworks require it.
| Mode | When |
|---|---|
on | Recommended. Full server-side state awareness; up to 2048 slots with a subscription (formerly “OneSync Infinity”). |
legacy | Only for very old scripts that expect every player on every client. Not recommended. |
off | Only for small servers without OneSync-dependent scripts, max 32 slots. |
With txAdmin you set OneSync under Settings → FXServer (“Advanced” section, option “OneSync: On (recommended)”). Don't set it in server.cfg as well then. Without txAdmin, put set onesync on in server.cfg.
Step 6: Connect and test
Start FiveM, press F8 and connect directly:
connect 203.0.113.10:30120
A domain works too: use the free avantahost.de subdomain from the network tab together with the port, e.g. connect yourserver.avantahost.de:30120. Your server appears in the public server list with the name from sv_hostname, unless you made it private.
Common errors
| Message | Cause and fix |
|---|---|
Couldn't find resource name | Folder name and ensure line don't match, or fxmanifest.lua sits one level too deep. |
Server license key authentication failed | Key wrong, deleted or created for a different IP. Check it in the portal and set it again. |
Failed to start in time | A resource takes too long to start (often an unreachable database). Increase “Resource Starting Tolerance” in txAdmin and check the database connection. |
oxmysql: Access denied / ECONNREFUSED | User, password or host in the connection string is wrong. |
| Players can't see each other | OneSync is off or set to legacy while scripts expect on. |
FiveM hosting with txAdmin
At AvantaHost txAdmin is set up out of the box with its own port, and you create databases in the panel. You bring your own Cfx.re key – it stays tied to your account.
View FiveM packages