Skip to content
Tutorials

FiveM server.cfg Explained: What Each Line Does and Where It Goes

ATY Development
·
·Updated ·
28 views
QBCoreESXQboxStandalone
FiveM server.cfg Explained: What Each Line Does and Where It Goes

Most broken FiveM servers are not broken by a script. They are broken by a server.cfg that grew by copy and paste until nobody knew which line did what. This guide walks through the file section by section, explains why order matters, and shows a layout that stays readable as your resource list grows.

What server.cfg actually is

The config file is not a settings file in the usual sense. It is a list of console commands that the server runs in order at startup, exactly as if you had typed them into the server console. That has two consequences:

  • Order matters. A resource started on line 40 cannot rely on something that only starts on line 80.
  • Anything you can type in the console can go in the file. That includes exec, which loads another config file, so you can split one long file into several smaller ones.

If you use txAdmin, it still reads a server.cfg; txAdmin just gives you an editor for it and handles starting and restarting the process. The rules below apply either way. The official reference for commands is the server commands page on the FiveM docs.

Network endpoints

The first lines usually define where the server listens:

endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

0.0.0.0 means listen on all interfaces. 30120 is the default port. If you run several servers on one machine, give each a different port and open both TCP and UDP for it in your firewall. A server that shows up in the list but cannot be joined is very often a firewall that only allows one of the two protocols.

set, sets and setr: the three kinds of convar

Convars are named variables that the server and resources read. How you define them decides who can see them:

  • set defines a convar on the server only. Use it for anything secret, such as database credentials.
  • sets defines a convar and publishes it in the server info, so it is visible in the server list and to anyone querying your server. Use it for tags, locale and descriptions.
  • setr defines a convar and replicates it to clients, so client scripts can read it. Useful for client-side options a resource expects, never for secrets.

A common mistake is writing setr or sets in front of a connection string because a tutorial did. If a value contains a password, it should be set and nothing else.

Server identity and listing

sv_hostname "My City RP | Serious RP"
sets sv_projectName "My City RP"
sets sv_projectDesc "Whitelisted serious roleplay"
sets tags "roleplay, serious, economy"
sets locale "en-US"
load_server_icon logo.png

The hostname and project name are what players see in the browser. Keep tags honest and short; players filter by them. The server icon must be a small square PNG placed next to your config file. If you want a private development server that does not appear in the public list, the usual approach is to blank the master server convar with sv_master1 "".

License key, slots and game build

sv_licenseKey "your_key_here"
sv_maxclients 48
set sv_enforceGameBuild <build>

The license key comes from the Cfx.re portal and ties the server to your account. Treat it like a password: anyone with it can run a server under your name.

sv_maxclients sets the slot count. Higher slot counts require OneSync to be enabled, which txAdmin exposes as a setting and which can also be set on the command line. Check the current limits for your tier on the docs rather than trusting an old forum post.

sv_enforceGameBuild forces clients onto a specific GTA game build. Many vehicles, clothing and map packs depend on a minimum build, so if a resource description says it needs a newer build, this is the line to change. Changing it forces every player to download that build, so do it deliberately and announce it.

Security-related lines

sv_scriptHookAllowed 0
sv_endpointprivacy true
  • sv_scriptHookAllowed 0 blocks clients from using ScriptHook-based mods. Leave it off on any public server.
  • sv_endpointprivacy true hides player IP addresses from other players in the player list data.

Avoid setting an rcon_password unless you have a specific tool that needs it. txAdmin and the live console cover what most owners used RCON for, and an exposed RCON is one more thing to attack.

The database connection string

Most QBCore, Qbox and current ESX setups use oxmysql, which reads a convar for its connection:

set mysql_connection_string "mysql://dbuser:dbpass@127.0.0.1/my_city?charset=utf8mb4"

Points worth checking when the database refuses to connect:

  • The database name in the string must already exist; oxmysql will not create it.
  • Special characters in the password can break the URL format. Either use a password without @, : or /, or URL-encode it.
  • Use 127.0.0.1 if the database is on the same machine. A remote database adds latency to every query.
  • Create a dedicated database user for the server. Do not use the root account.

Starting resources: ensure, start and categories

ensure name starts a resource, or restarts it if it is already running. start only starts it. In practice, use ensure everywhere.

Folders in square brackets, such as resources/[qb], are categories. The server searches inside them for resources, and you can ensure a whole category with ensure [qb]. That is convenient, but it gives up control over order inside the folder. Ensure the core pieces by name first, then the category:

# libraries and database
ensure oxmysql
ensure ox_lib

# framework core
ensure qb-core

# framework resources
ensure [qb]

# third-party and custom
ensure [standalone]
ensure [jobs]
ensure [maps]

The general order for any framework is: database driver, shared libraries, framework core, inventory and targeting, then everything that depends on them. If a resource throws errors about a missing export or an undefined object on boot, the fix is almost always to move its dependency higher. A resource's fxmanifest.lua can also declare dependencies, which makes the server refuse to start it until they are running.

Permissions

Admin permissions are ACE entries, also written in the config:

add_ace group.admin command allow
add_principal identifier.fivem:1234567 group.admin

Keep these in their own file. Framework-specific groups follow the same pattern but use the group names your framework expects, so check its documentation before copying lines from another framework's guide.

A layout that scales

Once a server passes a few dozen resources, one long file becomes hard to review. Split it:

  1. server.cfg: endpoints, identity, build, slots and the exec lines.
  2. secrets.cfg: license key, database string, any API keys. Never committed to Git, never pasted in Discord.
  3. permissions.cfg: ACE and principals.
  4. resources.cfg: every ensure, grouped and commented.
exec secrets.cfg
exec permissions.cfg
exec resources.cfg

Put secrets.cfg in your .gitignore if the server folder is under version control. When you ask for help, you can share the other three files without redacting anything.

Debugging a config that will not boot

  • Read the console from the top, not the bottom. The first error is usually the real one; later errors are fallout.
  • Watch for smart quotes. Copying from a website or document can turn " into curly quotes, which the parser will not read as quotes.
  • A line that does nothing is often a typo in a resource name. The console reports resources it could not find.
  • Comment out half the ensure lines with # to bisect a crashing resource instead of guessing.

Takeaway

Treat server.cfg as a startup script that runs top to bottom. Use set for anything secret, sets only for public info, and setr only for values clients need. Start the database driver and libraries before the framework, and the framework before everything else. Split secrets, permissions and resources into separate files so the main config fits on one screen and can be shared safely. If you are setting up from scratch, the official setting up a server guide is the reference to check current requirements against.