How to Make a FiveM Server
What you need
- A machine to run it on: your own PC for testing, or rented hosting for a public server. See FiveM server hosting.
- A Cfx.re account.
- A database server, usually MariaDB or MySQL.
- Basic comfort with files, folders and a command window.
Step 1: get a licence key
- Sign in to the Cfx.re portal with your account.
- Register a new server key.
- Enter the IP address of the machine and choose the server type.
- Copy the key. You will paste it during setup.
The standard key is free. Player slots are tied to Cfx.re's own tiers: FiveM's documentation says that more than 48 slots requires a paid subscription level.
Step 2: download the server files
Download the latest recommended server build, called the artifacts, from FiveM's official site. Choose the Windows or Linux version to match your machine. Extract it into an empty folder.
Step 3: start txAdmin
- Run the server executable from the folder you extracted.
- A browser window opens with txAdmin, the web panel that ships with the server.
- Link it to your Cfx.re account and create an admin password.
By default txAdmin listens on port 40120.
Step 4: install a database
Install MariaDB or MySQL and create an empty database for the server. Note the address, user name, password and database name. On a Windows test machine, a bundled package such as XAMPP is a quick way to get one running.
Step 5: choose a recipe
txAdmin offers recipes that install a ready-made base. The main choices are ESX, QBCore and Qbox. Pick one, enter your database details and let txAdmin download and configure it. To decide, read ESX vs QBCore vs Qbox.
Step 6: configure server.cfg
txAdmin creates this file for you. Check these lines:
sv_licenseKeyholds your key from step 1.sv_hostnameandsv_projectNameare your server's name.sv_maxclientsis the player limit.- OneSync is enabled. Modern frameworks need it.
endpoint_add_tcpandendpoint_add_udpuse port 30120.
Step 7: open the ports
Players connect on port 30120, both TCP and UDP. On rented hosting it is normally open already. At home you must forward it on your router and allow it through the firewall. Keep the txAdmin port closed to the public if you can.
Step 8: connect
Start the server from txAdmin. Open FiveM on your PC, press F8 and type connect followed by the server's address. For a server on the same machine, use connect localhost.
What to do next
- Make yourself an admin in txAdmin and in the framework.
- Set up automatic backups of the database and the server folder.
- Schedule restarts. Most servers restart every 6 to 12 hours.
- Add resources slowly. Install one script, test it, then add the next.
- Write your rules. See the shared core in GTA RP rules.
- Set up Discord. See Discord setup for GTA RP servers.
- Read the licence agreement before taking any money. See FiveM monetization rules.
Mistakes that cause the most trouble
- Leaked or cracked scripts. They often hide backdoors that give strangers control of your server.
- Too many scripts at once. When something breaks you will not know which one did it.
- No backups.
- Running everything as administrator or root.
- Opening to the public before testing with friends.
Related
FAQ
Is it free to make a FiveM server?
The software and licence key are free. You pay for hosting and for any paid scripts.
Do I need to know how to code?
Not to get a base server running. Customising it means working with Lua or JavaScript.
Can I run a FiveM server on my PC?
Yes, for testing. See free FiveM server hosting.
Which port does FiveM use?
30120 for players, TCP and UDP.
