Running FXServer

From FiveM
Jump to: navigation, search

FXServer is the next generation of CitizenFX server tooling. This page shows how to run it.

Running from Build Artifacts


  1. Make sure you have installed a newer Visual C++ redistributable, 2017 is fine ( direct link to the 2017 setup )
  2. Create a new folder (for example D:\FXServer ).
  3. Download the latest master branch build for Windows from the artifacts server.
  4. Extract the build.
    • Use any archiving tool (such as WinRAR or 7-Zip).
  5. Clone cfx-server-data in a new folder (other than your FXServer folder).
  6. Make a server.cfg in your server-data folder. You need to copy the example cfg below into the file.
  7. Run the server from the server-data folder. (cd /d D:\FXServer\server-data)
    • D:\FXServer\run.cmd +exec server.cfg (from a new cmd window)
  8. Generate a license code from and register for an account.


  1. Create a new folder (for example mkdir /root/myserver/server).
  2. Download the latest master branch build for Linux from the artifacts server (copy the URL for the latest server version and use wget <url> to download it).
  3. Extract the build using cd /root/myserver/server && tar xf fx.tar.xz (you need to have xz installed, on Debian/Ubuntu this is in the xz-utils package).
  4. Clone cfx-server-data in a new folder (other than your FXServer folder).
  5. Make a server.cfg file in your server-data folder (copy the example server.cfg file below into that file).
  6. Run the server from the server-data folder.
    • bash /root/myserver/server/ +exec server.cfg


  • If nothing happens when you run the run.cmd file with CMD or Powershell, make sure you have a newer Visual C++ redistributable installed. If you just double click the run.cmd and you get errors you know something is wrong which you can start Googling.
  • If you try and connect with the FiveM client and the FiveM client is just stuck on a message where it's trying to download a resource or load something two things could be going on:
  1. Your server has a firewall on it that is blocking your client from being able to download everything. Try completely disabling your firewall, the Windows firewall is quite aggressive and will silently block connections. You'll need to turn the Windows firewall off for the profile you're network is assigned to. If you're using linux you'll want to make sure UFW, or iptables isn't blocking your clients. Note, if disabling your firewall fixes the issue please don't just leave your firewall off forever, turn it back on and create exceptions for the ports that are needed. Enable firewall logging to find these ports if necessary.
  2. You may have just created and started your FXServer for the first time, the Cache and local server data was likely just created, stop / close the server, then start it again as normal and try and connect with your client again.
  • If you don't get any 'resources found', and it says 'Failed to start resource', you didn't 'cd' to the right folder.
  • If you get a lot of errors about citizen:/scripting/, you didn't use run.cmd.
  • If nothing happens at all except 'sending heartbeat', you didn't use run.cmd and failed to cd to the folder.
  • If no resources get started, and you can't connect, you didn't add +exec.
  • Mono errors (SIGSEGV, exception stack trace) are perfectly fine, and don't signify any error condition.
  • If you get 'Couldn't load resource sessionmanager :(' then in your server CMD or shell type in 'restart sessionmanager' and press enter. You should get a 'Stopping and Starting message if the command was successful. The alternative is to use rcon set up IceCon and input 'restart sessionmanager' - Note: I found that this only happens when FXServer has just generated the cache folder, a server restart after having just generated the folder also fixes the error.
  • On windows, you may wish to make a cmd file in the server-data folder with the run code in for ease.

  • Still not working or getting random issues like clients timing out for no reason? Try an older server build, I was having random annoying issues and they weren't making sense, using an older master build fixed them. Regression sucks but this is community driven :/. You're welcome to help make this better!

Porting Notes

If you have any more notes, write them here.

Loading Scripts

require doesn't exist anymore, any scripts/libraries should be loaded using the server_script directive in the resource manifest.

For example:

server_script "my_script.lua" -- load script 
server_script "" -- load a particular assembly into the .net appdomain
server_script "@resource_name/script.lua" -- load a script from another resource

To load files at runtime, you can use LOAD_RESOURCE_FILE (LoadResourceFile("resource_name", "file_name")), and for example if it is a Lua file you can use load(...) to load the Lua code, like in the following example:

function loadLuaFile(resource, file)
    return load(LoadResourceFile(resource, file), file)()

String Splitting

str:Split does not exist anymore, you should use the proper Lua functions for this. For the commonly copy-pasted stringsplit function, this'd be:

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    return t

Bitwise Operations

Lua 5.3 deprecated bit32, and the CfxLua runtime does not enable it. Bitwise operations now work using normal operators (&, |, ...) like in most other programming languages.


NeoLua is no longer in use, so the clr namespace does not exist anymore. If you need to run C# code, use the normal .NET runtime and server exports.


If you did any specific bitwise operations assuming during playerConnecting the source value is above 0x10000, this should not be needed anymore to use functions during playerConnecting.


An example server.cfg follows.

# only change these if you're using a server with multiple network interfaces
endpoint_add_tcp ""
endpoint_add_udp ""

start mapmanager
start chat
start spawnmanager
start sessionmanager
start fivem
start hardcap
start rconlog
start scoreboard
start playernames

# allow client mods such as Lamda Menu?
sv_scriptHookAllowed 1

# change this
#rcon_password yay

# a comma-separated list of tags for your server
# for example: sets tags "drifting, cars, racing" or sets tags "roleplay, military, tanks"
sets tags "default"

sv_hostname "My new FXServer!"

# nested configs!
#exec server_internal.cfg

# loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png

# convars for use from script
set temp_convar "hey world!"

# Uncomment to DISABLE your server coming up in the server list
#sv_master1 ""

# want to only allow players authenticated with a third-party provider like Steam (don't forget, Social Club is a third party provider too!)?
#sv_authMaxVariance 1
#sv_authMinTrust 5

# add system admins
add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don't allow quit
add_principal identifier.steam:110000112345678 group.admin # add the admin to the group

# remove the # to hide player endpoints in external log output
#sv_endpointprivacy true

# server slots limit (must be between 1 and 32)
sv_maxclients 32

# license key for server (
sv_licenseKey <your key here>

For more commands/variables, check cmdlist over rcon. Most commands/set functions can be executed over the command line too, similar to Quake.