Set Up Your First FiveM Server
From nothing to a server your friends can join: artifacts, licence key, server.cfg, the port that trips everyone up, and locking it down before you invite anyone.
6 minute read
This is the shortest path from nothing to a server your friends can join, with the reasoning behind each step rather than a list of commands to paste.
Budget about forty minutes. Most of it is downloading.
Everything here applies to FiveM Legacy. FiveM for GTAV Enhanced differs on a few points and they are called out as they come up.
What you need first
| Thing | Why |
|---|---|
| A copy of GTA V | Only to play. The server itself does not need one. |
| A Cfx.re account | To create the licence key, free. |
| Windows or Linux | 2 cores and 4 GB of RAM is enough to start. |
| An open port | 30120 by default, TCP and UDP. |
That last row is where most first attempts die, so it gets its own section below.
1. Get the server files
The server is called FXServer. Download the latest recommended build from
the Cfx.re artifacts page and put
it in its own folder, for example C:\FXServer\server.
Keep the server files and your own data in separate folders:
C:\FXServer\ server\ the artifacts, replaced on every update server-data\ your resources and your server.cfg
The reason is upgrades. When a new artifact comes out you delete server and
unpack the new one. If your resources folder lives inside it, you have just
deleted your server.
2. Get your licence key
Go to portal.cfx.re, sign in, and create a key. It asks for an IP address: use the machine that will run the server, and pick the correct type, since a key created for the wrong IP simply refuses to start.
The key is a secret. Anyone holding it can run a server as you and get it
revoked. It belongs in server.cfg, and server.cfg never goes in a public
git repository.
3. Write server.cfg
This is the file everything else hangs off. Rather than copying someone's and wondering what half of it does, build one with the server.cfg Generator: it writes the sections in the right order, uses convar names checked against the Cfx.re command reference, and explains each option as you set it.
The parts that matter on a first server:
# One line per protocol, both pointing at the same port.endpoint_add_tcp "0.0.0.0:30120"endpoint_add_udp "0.0.0.0:30120"# 32 slots and above need onesync on or legacy; above 64 needs on.set onesync onsv_hostname "My First Server"sv_maxClients 48# Get this from portal.cfx.resv_licenseKey changeme
Load order is not decoration
Resources start in the order they are listed. A resource that depends on another must come after it:
ensure oxmysqlensure ox_libensure es_extendedensure my_own_script
Nearly every "attempted to index a nil value" on a fresh server is a load order problem, not a broken script.
4. Open the port, properly
FiveM needs TCP and UDP on the same port. Opening only TCP produces the most confusing symptom in the whole hobby: the server appears in your own list, accepts your connection, and then hangs on "Connecting".
Three separate places can block it, and all three usually need doing:
- Windows Firewall or
ufwon Linux: allow 30120 TCP and UDP inbound. - Your router, if the machine is at home: forward 30120 TCP and UDP to the machine's local IP.
- Your host's firewall, if you rent a VPS. This one is a web panel, not the machine, and it is the one people forget.
To check whether it is really the port, have someone try to connect while you watch the server console. If nothing at all appears there, the traffic is not reaching you and the problem is network, not config.
5. Start it
From the server-data folder:
C:\FXServer\server\FXServer.exe +exec server.cfg
On Linux:
bash /home/fivem/server/run.sh +exec server.cfg
On Enhanced the executable is cfx-server.exe instead.
A healthy first start prints a line saying the server is listening, then a resource list. Two errors are common enough to name:
- "Could not find licence key" means
sv_licenseKeyis missing, wrong, or bound to another IP. - "onesync is not enabled" with more than 32 slots means
set onesync onis missing.
6. Add a framework, or do not
You do not need one. A framework gives you jobs, money, inventory and a character system; without one you have free roam, which is a perfectly good place to start.
If you do want one, pick a single ecosystem and stay in it:
| Framework | Character |
|---|---|
| Qbox | Actively maintained, modern Lua, built on ox_lib and ox_inventory. |
| QBCore | Very large script catalogue, older codebase. |
| ESX Legacy | The oldest, still widely used, most third-party scripts target it. |
Mixing them is the single most common way to end up with a server nobody can debug. Whichever you choose, the Job Generator and the Item Generator write the correct format for each of the three.
7. Lock it down before you invite anyone
A default configuration is not a safe one.
# Blocks modified game files. 2 also blocks unknown files.sv_pureLevel 1# Controls what clients are allowed to create.sv_entityLockdown relaxed# Trainers and menus. Leave this off.sv_scriptHookAllowed false
Then set up admin permissions properly with the
ACE Permissions Builder instead of granting group.admin
by hand. And before you install a single downloaded resource, read
how to spot a backdoored script. On a public
server it is a matter of when, not if.
Do not set rcon_password unless you actually use RCON. An unset password is
one fewer thing that can leak.
Where to go next
- fxmanifest.lua Builder when you write your first resource
- Resource Scaffolder for a working skeleton with the server-side checks already in place
- Blip Sprites and Vehicle Models, the two lists you will keep a tab open for