01
How the file is read, and its first two lines
server.cfg lives in the server's data folder (often called server-data), next to the resources folder. The server runs its lines one by one, from top to bottom, as if you were typing them into the console. A few rules to know:
- a line starting with
# is a comment: it is ignored. It is the clean way to disable a line without deleting it;
- values containing spaces go between straight quotes (
"), never curly quotes;
- three words define a variable:
set keeps it on the server, sets makes it public (it shows up in the server information, readable by anyone), setr also sends it to players. A password or a key therefore never goes with sets or setr;
- most settings are only read at startup: after a change, restart the server completely.
If you manage the server with txAdmin, there is no need to look for the file on disk: it opens and saves in txAdmin's configuration editor.
The file usually starts with the two network lines:
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
They tell the server which address and port to wait for players on. 0.0.0.0 means "every address on the machine", and 30120 is FiveM's default port. The game needs both, TCP and UDP, on the same port. To run two servers on one machine, give each a different port, on both lines. On a hosted server, keep the address and port created with the server: those are the ones that are open. The guide game server ports covers the rest.
02
Name, slots, keys and game version
sv_hostname "My server": the server's name, shown in the server list. It accepts FiveM colour codes (^1, ^2…).
sets sv_projectName "…" and sets sv_projectDesc "…": the project name and its short description, highlighted in FiveM's server list. They are public variables, hence sets.
sets tags "roleplay, francais": comma-separated keywords that help players find the server. sets locale "fr-FR" states the language.
load_server_icon logo.png: the server's icon in the list. The file must be a 96 × 96 pixel PNG image, placed in the server's data folder.
sv_maxclients 48: the number of slots. Above 32, OneSync must be enabled, and above 48 you need a key linked to a Cfx.re Element Club subscription.
sv_endpointprivacy true: hides players' IP addresses in the server's public information. Keep it on.
sv_licenseKey "…": the Cfx.re licence key, without which the server stops at startup. Creating one is explained in the guide FiveM licence key.
set steam_webApiKey "…": a Steam Web API key. Without it, the server does not know players' Steam identifiers; scripts that rely on them (older ESX versions, some ban systems) do not work. If you do not need it, set "none".
sv_enforceGameBuild 3095: the GTA V version forced on players, and therefore the available content (vehicles, clothing, interiors). Put it at the top of the file. Choosing the number is explained in the guide FiveM gamebuild.
set onesync on: enables OneSync, server-side world synchronisation, required above 32 players and by most recent frameworks. With txAdmin, set OneSync in its settings instead and do not write a second value in the file: everything is explained in the guide OneSync.
03
Resources, exec files and permissions
Starting resources. Each resource starts by its name, that is the name of its folder in resources:
ensure name starts the resource, or restarts it if it is already running: this is the command to use;
start name only starts it; you find it in older files, and it does the same thing at server startup;
ensure [folder] starts every resource in a category folder at once (a folder whose name is in square brackets, like [qb] or [standalone]). Handy, but you do not choose the order inside the folder.
Order matters. Resources start in the order of the lines. Put the database first (oxmysql, see the guide oxmysql) and the libraries (ox_lib), then the framework (es_extended, qb-core or qbx_core), then the scripts that depend on it. New additions follow the method in the guide installing a FiveM script.
Splitting the file with exec. exec ressources.cfg reads another configuration file as if it were pasted at that point. The path starts from the server's data folder. It is useful to keep resources or permissions separate, or to keep secrets in a file you never share.
Permissions (ACE). FiveM grants rights to groups, then puts players in those groups:
add_ace group.admin command allow
add_ace group.admin command.quit deny
add_principal identifier.license:0123456789abcdef0123456789abcdef01234567 group.admin
add_ace grants (allow) or removes (deny) a right for a group: here, every command for the admin group, except quit, which shuts the server down;
add_principal puts a player in a group, using one of their identifiers: license (the most reliable, visible on the player's page in txAdmin), discord or fivem.
ESX, QBCore and Qbox also have their own admin ranks, in the database or as dedicated ACE groups: follow your framework's documentation (see ESX, QBCore or Qbox).
04
A full commented example
Here is a complete server.cfg for an ESX roleplay server. Replace the example values with your own, and the resource names with those of your framework.
# --- Network: port 30120 over TCP and UDP ---
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
# --- Game version and OneSync (read at startup) ---
sv_enforceGameBuild 3095
set onesync on # without txAdmin; with txAdmin, set OneSync in its settings
# --- Server list showcase (public variables) ---
sv_hostname "My RP Server"
sets sv_projectName "My RP Server"
sets sv_projectDesc "French-speaking roleplay, Discord whitelist"
sets tags "roleplay, francais, whitelist"
sets locale "fr-FR"
load_server_icon logo.png
# --- Slots and privacy ---
sv_maxclients 48
sv_endpointprivacy true
sv_scriptHookAllowed 0 # blocks ScriptHook menus
# --- Database: set, never sets ---
set mysql_connection_string "mysql://fivem:password@127.0.0.1/fivem?charset=utf8mb4"
# --- Resources: database, libraries, framework, then the rest ---
ensure oxmysql
ensure ox_lib
ensure es_extended
ensure [esx]
ensure [standalone]
exec ressources-perso.cfg
# --- Administrators ---
add_ace group.admin command allow
add_ace group.admin command.quit deny
add_principal identifier.license:0123456789abcdef0123456789abcdef01234567 group.admin
# --- Keys: keep them secret ---
set steam_webApiKey "none"
sv_licenseKey "your_licence_key"
Before posting this file anywhere (on Discord to ask for help, for example), remove the licence key and the database password.
05
Common errors
- "Couldn't find resource": the name after
ensure does not match the folder name, or the resource is wrapped in an extra folder after unzipping (resources/myscript/myscript-main/). The fxmanifest.lua file must sit directly in the named folder.
- "No such export" at startup: a script calls a resource that has not started yet. Move the dependency's
ensure line higher (often oxmysql or the framework).
- Curly quotes (“ ”), copied from Discord or a word processor: the server treats them as text and the value is wrong. Retype them as straight quotes.
- A
server.cfg.txt file on Windows, when file extensions are hidden: the server cannot find its file.
- The same variable written twice (two
sv_maxclients, two sv_licenseKey): the last one read applies, and you can spend a long time wondering why the first is ignored.
- A secret set with
sets: it becomes readable by anyone in the server's public information. Change the password or key, then replace sets with set.
- A change with no effect: the server was not fully restarted.
Other console messages are decoded in the guide FiveM server errors.
06
On CloudFive
On a FiveM hosting plan, server.cfg is edited in the editor of the Files tab in the customer area, or in txAdmin's, which comes pre-installed. ESX, QBCore or Qbox install in one click with their MariaDB database, the file already written. A shared Patreon key is set up when the server is created, at no extra cost and limited to 48 players: beyond that, get your own Element Club subscription on the Cfx.re portal. Before editing the file, a backup from the customer area lets you roll back if something goes wrong.
07
Frequently asked questions
Where is FiveM's server.cfg?
In the server's data folder, next to the resources folder. With txAdmin, it opens directly in txAdmin's configuration editor, with no need to find the file on disk.
What is the difference between set, sets and setr?
set keeps the variable on the server, sets makes it public in the server information, and setr also sends it to players. A password, a key or a database connection string always goes with set.
What is the difference between ensure and start?
start starts a resource, ensure starts it or restarts it if it is already running. In server.cfg both do the same thing at startup, but ensure is the recommended command.
In what order should resources go in server.cfg?
First the database (oxmysql) and libraries such as ox_lib, then the framework (ESX, QBCore or Qbox), then the scripts that depend on it. A resource started before its dependency causes errors such as "No such export".
How do I grant admin rights in server.cfg?
Grant rights to a group with add_ace group.admin command allow, then put the player in that group with add_principal followed by their identifier (for example identifier.license:…) and group.admin. Then restart the server.