Cómo se hace

How to install ESX Legacy in FiveM

Install ESX Legacy from scratch: requirements, es_extended and its dependencies (oxmysql, ox_lib), importing the .sql, configuring mysql_connection_string and the correct ensure order.

The problem

You want to set up a FiveM server with the ESX Legacy framework but you don't know which resources to download, in what order to load them, or how to connect the database. On the first boot the console throws "attempt to index a nil value (ESX)" and nothing works.

The cause

ESX Legacy isn't a single resource: it's es_extended plus a chain of dependencies (oxmysql, ox_lib and the menu) that must be downloaded, with their SQL table imported and, above all, loaded in the right order. If a dependency is missing, the MySQL connection_string is wrong, or the ensure order is incorrect, the framework never initializes and any resource that depends on ESX receives a nil value.

The solution

Download es_extended and its dependencies, import the .sql into your database, set mysql_connection_string, and load the resources in this exact order in server.cfg (oxmysql → ox_lib → es_extended → your resources):

cfg
# server.cfgESX Legacy load chain

# 1) Database connection (oxmysql reads it from here)
set mysql_connection_string "mysql://user:password@localhost:3306/esx_legacy?charset=utf8mb4"

# 2) ensure order: dependencies ALWAYS before es_extended
ensure oxmysql       # database layer (must come first)
ensure ox_lib        # shared library used by ESX
ensure es_extended   # the framework (after its dependencies)

# 3) From here on, your resources that depend on ESX
# ensure my_esx_resource

Step by step

  1. 1.Prerequisites: have a working FXServer (artifacts) and an accessible MySQL/MariaDB server. Create an empty database, for example `esx_legacy`.
  2. 2.Download oxmysql (overextended/oxmysql), ox_lib (overextended/ox_lib) and es_extended from the official esx-framework/es_extended repository (Legacy release). Unzip each one into your `resources` folder using its exact folder name.
  3. 3.Import the SQL: inside es_extended there's a `.sql` file (e.g. `[sql]/es_extended.sql`). Import it into your database with phpMyAdmin, HeidiSQL or `mysql < es_extended.sql`. This creates the `users`, `items`, `jobs` tables, and so on.
  4. 4.Configure the connection: add `set mysql_connection_string "mysql://user:password@localhost:3306/esx_legacy?charset=utf8mb4"` to server.cfg with your real credentials. oxmysql reads this line to connect.
  5. 5.Set the correct ensure order: `ensure oxmysql` → `ensure ox_lib` → `ensure es_extended`, and only AFTER that your resources that use ESX. Dependencies always load before whoever consumes them.
  6. 6.Boot the whole server and check the console: you should see oxmysql connecting to the database and es_extended initializing with no red errors. If "attempt to index a nil value (ESX)" appears, it's almost always the ensure order: es_extended or one of your resources loaded before oxmysql/ox_lib.
  7. 7.Verify in-game: connect and check that you spawn with money, a job and the base inventory. If the player loads correctly, ESX is installed and running.

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.

How to install ESX Legacy on your FiveM server (step-by-step guide)