Getting started
Running a local FiveM server for development
Set up a local FiveM development server: running FXServer on your PC, connecting with localhost, sv_lan for offline testing, a separate dev database, fast restart and refresh workflow, matching production (game build, OneSync), and testing with two clients.
Overview
Editing scripts directly on a live server means every typo is a public outage. A local development server on your own PC lets you restart resources a hundred times an hour, break things freely and only ship what works. It takes ten minutes to set up.
01Setting it up
- Download the server artifacts for your OS — the same build as production.
- Copy your server-data (or a trimmed version) to your PC.
- Create a
fivem_devdatabase and import a copy of production data or the framework’s SQL. - Point
mysql_connection_stringat the dev database. - Start the server and connect with
connect localhost:30120in F8.
Offline testing with sv_lan
set sv_lan true
sv_hostname "DEV - local"
sv_maxclients 8With sv_lan true the server does not appear in the public list and skips licence key checks — handy for a laptop on the train. Remove it on anything public.
The edit–test loop
| Command (server console) | When |
|---|---|
ensure myres | After editing a resource (starts or restarts it) |
refresh | After adding a new resource folder or changing an fxmanifest |
stop myres | To test behaviour without it |
restart myres | Restart an already running resource |
Many client changes need you to be in the game when the resource restarts; UI changes are fastest with a dev server and hot reload — see NUI devtools. Errors appear in F8 and the server console — see the F8 console guide.
Match production
- Same
sv_enforceGameBuild— natives and DLC content depend on it. - Same OneSync mode; server-side natives behave differently without it.
- Same framework and ox_lib versions.
- Same Lua version setting (
lua54).
Testing multiplayer logic
Sync, ownership and events between players only show up with two clients. Use a second PC or a friend on the LAN (with sv_lan off if they connect over the internet). Entity ownership pitfalls are explained in network IDs and ownership.
Frequently asked questions
How do I run a FiveM server on my PC for testing?
Download the server artifacts, set up server-data and a dev database, start FXServer and connect with connect localhost:30120.
Do I need a licence key for a local server?
Not with sv_lan true, which keeps the server LAN-only and skips the key check.
How do I reload a script without restarting the server?
ensure <resource> in the server console (or restart). Use refresh first for new resources.
Should the dev server use the live database?
No. Use a copy, so testing cannot damage real player data.
Need this built, not just explained?
Ten years of FiveM work, from Lua to NUI
Custom resources, React NUI, ESX / QBCore / Qbox integration, OneSync performance audits and security reviews — plus the websites and SEO around your server brand.
Related guides
- Getting startedWrite your first FiveM script, step by stepCreate a folder resources/my_first, add an fxmanifest.lua with fx_version 'cerulean', game 'gta5', a client_script and a server_script, then write a client command that loads a model with RequestModel, waits for HasModelLoaded, spawns it with CreateVehicle and seats the player with SetPedIntoVehicle. Add ensure my_first to server.cfg, restart, and type /car adder in game.
- EngineeringUsing Git to manage FiveM resourcesInitialise a repository in your server-data folder (or per script), commit resources and configs, and ignore caches, logs, txData and anything secret. Move the licence key, database password and tokens into a separate secrets.cfg that is exec’d but never committed. Use Git LFS or keep huge streamed assets out of the repo, work on branches, push to a private remote, and deploy with git pull on the server.
- Getting startedSetting up VS Code for FiveM scriptingInstall the Lua extension (Lua Language Server by sumneko/LuaLS). Clone Overextended’s fivem-lls-addon — the replacement for the discontinued CfxLua IntelliSense extension — into a folder for Lua addons, point workspace.userThirdParty at that folder in a .luarc.json, and add ox_lib to workspace.library. For JavaScript/TypeScript, install @citizenfx/client and @citizenfx/server typings.
- Getting startedWhere FiveM errors appear and how to read themClient script errors appear in the F8 console in game; server script errors appear in the server console (or txAdmin’s Live Console). A SCRIPT ERROR: @resource/client.lua:23: attempt to index a nil value (local 'data') line tells you the resource, the file, the line number and what went wrong. Read the first error, not the last — later errors are often consequences of the first.