Cómo se hace

FiveM server.cfg: example explained

A FiveM server.cfg commented from top to bottom: endpoints, sv_maxclients, OneSync, licenseKey, ensure order and secrets in a separate file. Ready to copy and adapt.

The problem

You have a FiveM server (txAdmin or manual) but you don't understand what each line of server.cfg does, in what order the resources must load, or how to enable OneSync to go past 32 players without everything crashing.

The cause

server.cfg is the file that boots your server: it defines the network connection, limits, license, OneSync and WHICH resources load and IN WHAT ORDER. If a directive is mistyped or a resource loads before its dependency, the server won't start or your scripts fail with errors like "nil value".

The solution

Here is a complete, commented example server.cfg. Every block is explained: network endpoints, hostname, player count, OneSync, the licenseKey (from keymaster, never share it), the MySQL connection string, the correct ensure order (dependencies first) and admin permissions. Sensitive keys go in a separate secrets.cfg loaded with exec.

cfg
# ===========================================================
#  Example server.cfgFiveM (commented line by line)
# ===========================================================

# --- 1. Network / endpoints ----------------------------------
# Port the server listens on (TCP for the list, UDP for gameplay).
# 0.0.0.0 = listen on all interfaces. 30120 is the default port.
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

# Hide your real IP/endpoint in the server list (recommended).
sv_endpointprivacy true

# --- 2. Server identity --------------------------------------
# Name shown in the list. Supports colors with ^1, ^2, etc.
sv_hostname "^2Crxative-M ^7| ESX Roleplay ^8[EN]"

# Max players. Above 32 you NEED OneSync (below).
sv_maxclients 64

# Locale and metadata for the server list.
sets locale "en-US"
sets tags "esx, roleplay, english"
sets Discord "discord.gg/your-server"

# --- 3. OneSync ----------------------------------------------
# OneSync syncs entities on the server. REQUIRED for > 32 players.
#   on        -> recommended for modern servers
#   legacy    -> old compatibility mode
# With OneSync 'on' you can raise sv_maxclients up to 1024 (if your VPS handles it).
set onesync on

# --- 4. License (SECRET!) ------------------------------------
# Your key from https://keymaster.fivem.net  —  NEVER push it to GitHub
# or share it. Ideally move it into secrets.cfg (see below).
sv_licenseKey "YOUR_KEYMASTER_LICENSE_KEY"

# Steam Web API token (optional, improves player identifiers).
# set steam_webApiKey "YOUR_STEAM_WEB_API_KEY"

# --- 5. Database (oxmysql) -----------------------------------
# MySQL/MariaDB connection string used by oxmysql/ESX.
# Also a secret: move it to secrets.cfg in production.
set mysql_connection_string "mysql://user:password@localhost:3306/esx_db?charset=utf8mb4"

# --- 6. Loading resources (ORDER MATTERS!) -------------------
# Golden rule: DEPENDENCIES go BEFORE whatever uses them.
# 'ensure' = starts the resource and restarts it if already running.

# 6.1 Base dependencies (very first)
ensure oxmysql          # database layer
ensure ox_lib           # shared library (cache, UI, callbacks)

# 6.2 Framework
ensure es_extended      # ESX LegacyMUST come before any ESX script

# 6.3 Player / world resources (depend on ESX + ox_lib)
ensure ox_inventory
ensure esx_menu_default
ensure esx_society
ensure esx_jobs

# 6.4 Your own resources (last, everything they need is ready)
ensure my_resource_hud
ensure my_resource_garage

# --- 7. Admin permissions (ACE) ------------------------------
# add_ace: grants a permission to a principal.
# add_principal: maps an identifier (license/steam) to a group.
# Here 'group.admin' gets full access ("command") and a player becomes admin.
add_ace group.admin command allow
add_principal identifier.license:PUT_YOUR_LICENSE_HEX_HERE group.admin

# Allow ESX to manage the admin group (typical example).
add_ace group.admin esx.admin allow

# --- 8. Secrets in a separate file ---------------------------
# Instead of leaving licenseKey / mysql_string here, create them in
# 'secrets.cfg' (add it to .gitignore) and load it with exec:
# exec secrets.cfg
#
# Example secrets.cfg:
#   sv_licenseKey "..."
#   set mysql_connection_string "mysql://..."

Step by step

  1. 1.Create or edit server.cfg at the root of your server (next to the resources/ folder).
  2. 2.Set endpoint_add_tcp/udp to "0.0.0.0:30120" and add sv_endpointprivacy true so your IP isn't exposed.
  3. 3.Adjust sv_hostname, sv_maxclients and locale. If you go over 32 players, enable OneSync with `set onesync on`.
  4. 4.Paste your sv_licenseKey from keymaster.fivem.net and the mysql_connection_string for oxmysql. NEVER push them to GitHub.
  5. 5.Order the `ensure` lines: oxmysql and ox_lib first, then es_extended, then resources that depend on ESX, and your own scripts last.
  6. 6.Grant permissions with add_ace/add_principal using your real identifier.license (find it with the `status` command or in txAdmin).
  7. 7.Move licenseKey and mysql_connection_string into a separate secrets.cfg, add it to .gitignore and load it with `exec secrets.cfg`.
  8. 8.Restart the full server to apply the ordering and OneSync changes.

Different case?

Paste your error in the AI tool and get the fix instantly.

Try the tool

Related guides

Last updated: 2026-06-29. Crxative-M is not affiliated with Cfx.re or Rockstar Games.

FiveM server.cfg: full example explained (OneSync, licenseKey, ensure)