START HERE·SET UP YOUR MACHINE·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this whole lesson - every step, code block, and the exact console errors - plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.
Start Here · Set up your machine

Your test server and the resources folder

To run your own code, you need your own little server to test it on. Not a public server, not a paid host, just a quiet copy of FiveM running on your own PC that only you can see. By the end of this lesson you will have downloaded the server program, gotten it running through txAdmin, joined it from FiveM, and found the exact folder where every script you ever write will live. The full production build, with a real host, a database, and security, lives in Track A. Here we get a test server up fast.

You'll build
A local FiveM test server running on your own Windows PC that you can join from the FiveM client, with a resources folder ready for your first script.
Time
~30 minutes
Difficulty
Beginner
You need
You finished "Set up VS Code for FiveM". A Windows PC, an internet connection, and FiveM installed (the same client you play on).
You'll learn
What a test server is, how to install and run one locally, where the resources folder lives, and the one rule that decides whether your code loads.
BEFORE YOU START

What a test server is

A test server is your own private FiveM server running on your PC, just for you. Think of it like a rehearsal stage. The real show is a public server with hundreds of players. The rehearsal stage is empty, lit, and yours, so you can walk onto it, try a line, see what breaks, and try again. Nobody is watching and nothing is at stake.

When you write code for FiveM, you do not test it on a server full of strangers. You test it on this private copy first. It behaves like a real server in every way that matters, except the only player who ever connects is you.

A handful of words come up the moment you touch one. Here they are, defined once, so the rest of the lesson reads cleanly.

Vocabulary

Server artifact
The FiveM server program itself. It is the actual software you download and run to host a server. You start it, and it becomes your server. People also call it FXServer, after the file you run.
txAdmin
A control panel for your server that opens in your web browser. It ships inside the artifact, so you do not install it separately. You use it to start, stop, and watch your server.
server.cfg
A plain text file that is your server's settings list. It tells the server what to load and how to behave when it starts up. You edit it in VS Code like any text file.
resources folder
A folder on your server where every piece of code lives. Each thing you build sits in its own subfolder inside here. Nothing outside this folder counts as code your server can run.
ensure
A one-word command you write inside server.cfg. Writing ensure myresource tells the server: start that resource when you boot up. No ensure line means the resource sits there unused.
License key
A free code from Cfx.re that proves your server is allowed to run. It is a string starting with cfxk_ that you paste into server.cfg. Every FiveM server needs one, including a private test server.

Why you need one

You already ran Lua in the browser sandbox in an earlier lesson, so a fair question is: why bother with a whole server?

Because the browser sandbox runs plain Lua only. Lua is the programming language FiveM uses. The sandbox can run the language itself, things like printing text and doing math, and that is perfect for learning how the language works. But FiveM is more than the Lua language. FiveM adds a huge set of its own features on top: commands players type, events that fire when something happens in the game, and natives, which are the built-in functions FiveM gives you to do FiveM things like spawn a car or heal a player.

The Lua language is the alphabet. FiveM is the whole vocabulary written in that alphabet. The browser sandbox knows the alphabet, so it can spell. It does not know FiveM's vocabulary, so the moment your code says something only FiveM understands (a command, an event, a native), the sandbox has no idea what you mean. Only a real server does. That is the line: plain language runs in the browser, anything FiveM-specific needs a server.

So the sandbox is great for the language, and useless the second you reach for a real FiveM feature. The test server is where those features actually run. That is the whole reason you set one up.

How the pieces fit

Three things work together: the server program, your config file, and your resources folder. Here is how they sit on disk once a server is set up.

text
C:\FXServer\
  server\            the artifact: the server program you downloaded
  server-data\       everything your server reads and runs
    server.cfg       the settings file: what to load
    resources\       every piece of code lives in here
      myresource\    one resource, in its own folder
        fxmanifest.lua
        server.lua

Read it top to bottom. The server folder holds the artifact, the program itself. The server-data folder holds the two things you actually touch as a developer: server.cfg and the resources folder. When the server boots, it reads server.cfg, sees which resources you asked for, and starts them.

Here is the rule that trips up every single beginner, so lock it in now. A resource loads only if both of these are true:

  1. It is sitting inside the resources folder, in its own subfolder.
  2. Its name is written in server.cfg on an ensure line.

Miss either one and the server will not run your code. A resource in the folder with no ensure line just sits there ignored. An ensure line pointing at a folder that is not there gives you an error. Both conditions, every time.

Build your test server

This is the do-it-now walkthrough. You will end with a server you can join. Each step tells you what to expect before you do it, the exact move, and what you should see when it worked. Go in order and do not skip a step. Track A is where you go deep on hosting and databases later; right now the only goal is a server running on your own PC.

Download the Windows server artifact

You have the FiveM server program unzipped into C:\FXServer\server.

Predict. You are about to download the server program, the actual software that becomes your server. Guess what form it arrives in: a single .exe you double-click, or a zip you have to unpack?

Do. Open the official Cfx.re Windows artifacts page (linked in References, the address is https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/). The list is sorted with the newest build at the top. Click the newest one, then download the file named server.7z inside it.

Make a folder at C:\FXServer and a folder called server inside it. Using 7-Zip (free, linked in References), extract the contents of server.7z into C:\FXServer\server. Download only from this official Cfx.re page. Skip Discord mirrors and random upload sites.

What you should see. Inside C:\FXServer\server you now have a file called FXServer.exe sitting next to several .dll files and folders. That FXServer.exe is the program you run in a later step. If you only see the .7z file and no FXServer.exe, you downloaded it but have not extracted it yet.

Make the server-data folder

You have an empty server-data folder with a resources folder and a blank server.cfg inside it.

Predict. The program lives in server. Your code and settings live somewhere separate. Guess why we keep them in two different folders instead of one.

Do. Next to the server folder, create a second folder: C:\FXServer\server-data. Inside server-data, create one folder named exactly resources. Then open VS Code, open the server-data folder, and create a new empty file named exactly server.cfg (all lowercase, no .txt on the end).

What you should see. On disk you now have this:

text
C:\FXServer\
  server\            (from step 1)
  server-data\
    server.cfg       (empty for now)
    resources\       (empty for now)

We keep the program and the data apart so that when a new artifact comes out, you replace the server folder and never touch your code in server-data. Your work survives every update.

Get a free Cfx.re license key

You have a key starting with cfxk_ copied to your clipboard.

Predict. Every FiveM server, even a private one only you can see, has to prove it is allowed to run. Guess where that proof comes from: your FiveM game account, or a separate server registration?

Do. Open the Cfx.re key portal at https://portal.cfx.re/ (linked in References) and sign in with the same Cfx.re or Discord account you use for FiveM. Click Server keys, then New server key. For the IP type choose localhost (it is a private test server on your own PC), give it any label like my test server, and create it. The portal shows you a key that looks like cfxk_.... Copy it.

What you should see. A new entry in your server keys list and a key string on screen that begins with cfxk_ followed by a long run of letters and numbers. That string is what proves your server may run. It is free, and you can make more later.

Write the starter server.cfg

server.cfg has your license key and an ensure line for the chat resource.

Predict. The server reads server.cfg top to bottom on boot. Guess what happens if the license key line is missing or wrong when it starts.

Do. In VS Code, open the empty server.cfg from step 2 and paste this in, replacing cfxk_PASTE_YOURS_HERE with the key you copied in step 3:

text
# network
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
 
# identity
sv_hostname "My Test Server"
sv_maxclients 8
 
# license key from https://portal.cfx.re/
sv_licenseKey cfxk_PASTE_YOURS_HERE
 
# resources
ensure chat

Save the file. The chat resource ships inside the artifact, so that ensure chat line already points at something real.

What you should see. A saved server.cfg with your real key on the sv_licenseKey line. If you left the placeholder text in by mistake, the server will refuse to start in the next step and tell you the license key is invalid.

Start FXServer and let txAdmin set up

A console window is open and txAdmin is waiting for you in the browser.

Predict. You are about to double-click FXServer.exe. Guess what opens: the game, a settings window, or something else.

Do. Go to C:\FXServer\server and double-click FXServer.exe. A black console window opens. On a fresh setup, it prints a line telling you txAdmin is starting and to open http://localhost:40120 in your browser. The first time, txAdmin shows a PIN in that black window; type the PIN into the browser page to claim the panel and create your admin login.

When txAdmin asks how to set up the server, point it at the server-data folder you made in step 2 (it may call this an existing server or a local folder). Let it finish.

What you should see. A black console window full of startup text, and a txAdmin setup page in your browser. Leave the black window open the whole time you work; closing it shuts the server down.

Open txAdmin and start the server

txAdmin shows your server as online.

Predict. txAdmin is the control panel. Guess where in your setup it actually runs: as another program you installed, or inside the artifact you already downloaded?

Do. In your browser, open this address:

text
http://localhost:40120

localhost means "this same PC", and 40120 is the door txAdmin listens on by default. Log in with the admin account you just made. On the dashboard, press the Start button for the server.

What you should see. The status flips to running, and the Live Console tab inside txAdmin fills with startup lines ending in something like Server started. That Live Console is the same text scrolling in the black FXServer window; it is where your script output will land in later lessons. txAdmin did not need a separate install: it shipped inside the artifact.

Join your server from FiveM

You are standing in your own test server.

Predict. Your server is running on this PC. Guess the address you connect to from the FiveM client to reach a server on the same machine.

Do. Open FiveM (the same client you play on). Press F8 to open the client console, type the line below, and press Enter:

text
connect localhost

FiveM connects to the server on your own PC and loads you in.

What you should see. The loading screen, then your character spawned in the world. You are now standing in the test server you just built. This is the rehearsal stage. Press F8 again to close the console.

Find the resources folder and the ensure rule

You know exactly where your code goes and how to switch it on.

Predict. You already wrote ensure chat to load the built-in chat. Guess what you will write later to load a resource you build yourself in a folder called myresource.

Do. In VS Code, keep C:\FXServer\server-data open. Look at the resources folder: that is where every resource you ever build will live, each in its own subfolder. Look back at server.cfg: the ensure chat line is what switched the built-in chat resource on.

What you should see. An empty resources folder waiting for your first subfolder, and a server.cfg whose ensure lines are the on switches. When you build myresource in the next module, it goes in resources\myresource\, and you add one line, ensure myresource, to server.cfg. Folder plus ensure line: that is the whole rule.

How it works

You have a running server you can join. Now connect the dots so you are deciding, not just clicking, the next time you touch this.

The artifact is the program, server-data is your stuff

The download in step 1 is the server artifact: the actual program, FXServer.exe, that becomes your server when you run it. It never changes while you work; you only swap it out when a new build comes out. Everything you actually edit, your server.cfg and your resources folder, lives in the separate server-data folder. Keeping them apart is why an artifact update never touches your code.

txAdmin is the dashboard, the Live Console is your window in

You never had to install txAdmin separately, because it ships inside the artifact and starts automatically when you run FXServer.exe. It opens in your browser at http://localhost:40120 and lets you start, stop, and watch the server. The Live Console tab is the one to remember: in later lessons, every print your code runs shows up there. It is the same text as the black FXServer window, just in the browser.

The license key is what lets the server run at all

The sv_licenseKey line you pasted in step 4 is not optional, even for a private server. FiveM checks it against Cfx.re when the server boots (the Authenticated with cfx.re Nucleus line in your expected output is that check passing). No valid key, no server. You got yours free from the portal, and it is tied to your account, so treat it like a password and do not paste it in public.

The one rule that loads code

Loading a resource always takes both halves. The folder has to be inside resources, in its own subfolder, and its name has to appear on an ensure line in server.cfg. You saw both halves already: the built-in chat resource sits in the artifact's resources, and your ensure chat line switched it on. Your own code follows the exact same pattern in the next module.

Two things must be true for the server to load your resource. What are they?

First, the resource has to be inside the resources folder, in its own subfolder. Second, it has to have an ensure line in server.cfg that names it, like ensure myresource. Both at once. In the folder but no ensure line means it sits there unused. An ensure line with no matching folder gives you a "does not exist" error. Folder plus ensure, every time.

Common beginner mistakes

These account for almost every "it will not start" or "my code is not loading" message a beginner ever sends. Read the symptom, apply the fix.

SymptomFix
Invalid license key specified (or server quits right after starting)The sv_licenseKey line is missing, still has the cfxk_PASTE_YOURS_HERE placeholder, or got a stray space. Paste the real key from https://portal.cfx.re/ with nothing after it, save server.cfg, and start again.
FXServer.exe will not run, or the window flashes and closesYou ran it before extracting, or extracted only some files. Extract the whole server.7z into C:\FXServer\server so FXServer.exe sits next to the .dll files, then run it from there.
Resource myresource does not existThe server cannot find the folder. Either the folder is not inside the resources folder, or the name in your ensure line does not match the folder name exactly. Lua and FiveM are case sensitive, so MyResource and myresource are different. Make the folder name and the ensure name identical.
The resource is in the folder but never startsThere is no ensure line for it in server.cfg. A resource sitting in the folder does nothing on its own. Add the line ensure myresource to server.cfg and restart the server from txAdmin.
You edited server.cfg but nothing changedYou almost certainly edited the wrong server.cfg, or saved it as server.cfg.txt. There can be more than one on a PC. Open the exact file inside the server-data folder your running server uses, make sure the name has no .txt on the end, save it there, and restart.

What you can do now

  • Explain what a test server is: your own private FiveM server on your PC, just for testing.
  • Download the Windows server artifact and unzip FXServer.exe into its own folder.
  • Make a server-data folder with a resources folder and a server.cfg next to the artifact.
  • Get a free Cfx.re license key from the portal and paste it into sv_licenseKey.
  • Start FXServer, open txAdmin at http://localhost:40120, start the server, and join it from FiveM with connect localhost.
  • State the one rule for loading code: a resource must be inside the resources folder AND named on an ensure line in server.cfg.

You have a stage to rehearse on, you can join it whenever you want, and you know the one rule that makes code load. The slow part is behind you. From here on it is building.

Try it yourself

Next up is the module Your first resource, starting with the lesson What a resource really is, where you build the myresource folder your ensure line is already waiting for.