FiveM Resource Start Order: Why It Breaks Servers
New Origins Studio engineering · published 2026-09-02 · updated 2026-09-02 · 9 min
The short answer
FiveM starts resources in the order server.cfg lists them, and a resource that queries a database or calls another resource's export during its own startup needs that dependency already running, not merely installed somewhere in the file. The reliable order is framework, then database layer, then shared libraries, then inventory, then everything that depends on them — reversed order produces nil-value errors that look exactly like a broken script but are actually a sequencing mistake.
Start order is a dependency graph, not a preference
A resource's startup code often does more than register events — it queries the database for its own tables, reads another resource's exported config, or registers itself with a framework that has to already exist to accept the registration. Every one of those actions assumes something else is already running, not just installed. server.cfg doesn't understand your intent; it starts resources top to bottom, in the order the file lists them, and whatever a resource's startup code reaches for has to already be alive when it reaches.
That's why "framework → database → shared libraries → inventory → everything else" isn't a style preference, it's the actual shape of the dependency graph in most FiveM stacks: the framework's own startup often talks to the database, shared libraries sit under both the framework and gameplay resources, inventory sits under the framework and above anything that gives or takes items, and gameplay resources sit on top of all of it.
What wrong order looks like in console
The signatures are consistent enough to recognize on sight, and they're easy to mistake for a broken script rather than a sequencing problem:
- "attempt to call a nil value (global 'exports')" or similar — the resource tried to call another resource's export before that resource had registered it.
- "attempt to index a nil value" naming a framework object or shared table — something the framework provides hadn't been set up yet when this resource's startup code ran.
- A database query erroring or timing out immediately on server start, then working fine for the rest of the session — the database connector resource wasn't ready yet on the one occasion it mattered: startup.
- A resource that starts with no console errors at all, then breaks the instant a player triggers its first interaction with another resource — its own startup didn't need the dependency, but the feature does, and the dependency still isn't running.
ensure vs. start — and why ensure is the server.cfg default
Per the official server commands reference (docs.fivem.net): start only starts a resource if it's currently stopped, and does nothing if it's already running by some other means. ensure restarts the resource if it was already started, or starts it if it wasn't — which makes it idempotent, and is why nearly every server.cfg uses ensure rather than start for its resource list. refresh rescans the resources folder and makes new resources available to start, but doesn't start anything by itself.
The fxmanifest dependency/dependencies field is a separate mechanism: it declares that a resource requires another one to be present, and current docs.fivem.net material describes it as a load-before requirement rather than detailing exactly how far the server goes to auto-resolve start order from it. Treat explicit, ordered ensure lines in server.cfg as the practice you control directly — it's what the rest of the FiveM ecosystem relies on regardless of what a loader might resolve automatically.
A worked server.cfg ordering example
This is a generic, illustrative shape — substitute your actual framework and libraries — showing the layers in the order they need to start:
- Layer 1 — core data and shared libraries: ensure oxmysql, then ensure ox_lib.
- Layer 2 — framework: ensure qbx_core (or your framework's core resource).
- Layer 3 — resources the framework's own startup expects to exist: ensure ox_inventory, ensure ox_target.
- Layer 4 — your bridge/adapter layer, if your stack uses one, sits after the framework and before anything that depends on it.
- Layer 5 — gameplay resources that depend on everything above: banking, jobs, garages, and anything else purchased or built on top of the stack.
Diagnosing an order problem after the fact
If a resource is already installed and misbehaving in a way that looks order-related, the fast check is to move its ensure line to the very end of server.cfg (after everything else) and restart — if the errors disappear, order was the cause and you can now find the real minimum position by moving it earlier in small steps. If two or more resources are involved and it isn't obviously an order problem, that's a conflict rather than a sequencing issue — see our guide to diagnosing FiveM script conflicts for the bisection method that isolates which one.
Questions, answered directly
What does "attempt to call a nil value" mean in FiveM?
The code tried to call something — usually an export or a global function — that doesn't exist yet at that point in execution. The most common cause is a dependency that hasn't started yet, closely followed by a typo in the export or function name.
What is the correct FiveM resource start order?
As a general shape: core data and shared libraries first (database connector, shared utility libraries), then the framework, then resources the framework's own startup depends on (like inventory), then everything else that depends on all of the above. The exact order depends on your specific stack's dependencies.
Should I use ensure or start in server.cfg?
ensure, for nearly every line. It restarts the resource if it's already running or starts it if it isn't, which makes server.cfg behave the same way on every boot. start only acts if the resource is currently stopped, which can silently do nothing if something else already started it.
Does the order of resources in server.cfg actually matter?
Yes, whenever a resource's startup code reaches for something another resource provides — an export, a database table, a registered framework object. server.cfg starts resources in file order, so anything a resource depends on at startup must be listed, and actually running, before it.
Read next
More from frameworks — Qbox, QBCore, ESX — choosing one, moving between them, and what a bridge owes you.
Qbox vs QBCore vs ESX Legacy in 2026: Choosing Your Framework
9 minAn honest comparison of FiveM's three major frameworks in 2026 — ecosystems, conventions, migration risk — from a studio that ships for all three.
Framework Lock-In: Why Switching Costs More Than Choosing
7 minMost FiveM servers pick a framework once and pay for it forever. What actually welds a server to QBCore or ESX, and how to buy resources that keep the door open.
The Complete FiveM Server Stack: Every Layer, in the Right Order (2026)
16 minEvery layer a FiveM RP server needs, from framework to database to jobs, banking, and MDT, with the build order and the failure risk at each step.


