In short
A server thread hitch warning means the FiveM server's main thread could not finish a frame on time and stalled for the stated number of milliseconds. Seeing it a few times at startup is normal. If it keeps repeating during gameplay, the cause is a heavy script, slow database queries or not enough CPU power; the profiler record command shows which one is responsible.
In this guide
- What exactly does the warning mean?
- What is normal and what is a problem?
- Finding the cause: script, database or CPU?
- Step 1: Find the bottleneck with the profiler
- Step 2: Fix script-related hitches
- Step 3: Fix database-related hitches
- Step 4: Confirm a CPU-related hitch
- If your hardware is not enough
- Keeping hitches from coming back
- Quick checklist
- Next step
The server thread hitch warning tells you that the FiveM server's main thread (server thread), which runs the game logic, could not complete a loop on time and stalled for the duration shown in the message. Seeing it a few times while the server starts is normal. If it keeps repeating during gameplay, there are three likely causes: a heavy script, slow database queries or not enough CPU power. This guide shows how to tell which one you are facing and the permanent fix for each.
What exactly does the warning mean?
The line you see in the console usually looks like this (the duration is an example):
server thread hitch warning: timer interval of 312 millisecondsFXServer runs server-side Lua and JavaScript code, event handlers and framework logic one after another on a single main thread. If this thread takes longer than expected to finish a step, nothing else is processed during that time: player commands wait, the inventory does not respond and vehicles sync late. The millisecond value in the warning shows how long that freeze lasted.
The similar-looking network thread hitch warning is about the network thread and usually points to network or host-side problems. This guide focuses on the server thread warning.
What is normal and what is a problem?
- Normal: a few warnings while the server starts, while a large resource starts, or during a txAdmin restart. Hundreds of files and scripts load at these moments.
- Worth investigating: warnings several times a minute during gameplay, especially ones that line up with a specific action (taking out a vehicle, opening the inventory, a paycheck).
- Urgent: warnings that keep flowing even when the server is empty, or values in the hundreds of milliseconds.
Finding the cause: script, database or CPU?
| Source | Typical symptom | First check |
|---|---|---|
| Script | The warning comes with a specific action or at fixed intervals (e.g. every 10 minutes) | Profiler recording, recently added scripts |
| Database | During saves, purchases, taking out vehicles; gets worse as players increase | oxmysql slow query warnings |
| CPU | Warnings everywhere, all the time; seen even on an empty server | Host CPU usage and steal value |
Step 1: Find the bottleneck with the profiler
FXServer's built-in profiler shows how much time each resource spends on the main thread. At a moment when warnings are frequent, run this in the server console (or the txAdmin live console):
profiler record 500
profiler viewprofiler record 500 records the next 500 server frames. When recording finishes, profiler view gives you a link you can open in your browser. Look for long bars on the timeline: under each bar you see the resource name and the running function. If one resource keeps producing long bars, that is the problem script. For the official walkthrough of the profiler, see the docs.fivem.net documentation.
If you cannot access the profiler, the classic method works: on a test server, stop suspicious scripts one by one with the stop command and see whether the warnings stop.
Step 2: Fix script-related hitches
The most common patterns that lock up the main thread on the server side:
- Loops with very short waits: server loops that run with
Wait(0)and scan every player. - Bulk save operations: periodic functions that save all players at once. This is the classic cause of hitches that come at fixed intervals.
- Large JSON operations and file writes: encoding large tables with
json.encodeand writing them to disk withSaveResourceFileon every event. - Synchronous database calls: blocking queries in old mysql-async scripts.
A simple example of spreading out a bulk save:
-- Bad: saving all players in the same frame
-- for _, id in ipairs(GetPlayers()) do SavePlayer(id) end
-- Better: spreading saves over time
CreateThread(function()
while true do
Wait(600000) -- every 10 minutes
for _, id in ipairs(GetPlayers()) do
SavePlayer(id)
Wait(50) -- short wait between each player
end
end
end)Proper waits in server-side loops
Almost no server-side work needs to run every frame. An anti-cheat check of player positions can run once a second, paychecks on the scale of minutes, and vehicle cleanup far less often. Ask how often a loop really needs to run and set its wait time accordingly. If you do heavy work at long intervals, split it into chunks as in the example above instead of processing every player at once. The same logic applies to timers created with SetTimeout: dozens of timers firing at the same moment also cause hitches.
Client-side scripts do not cause server hitches, but they lower player FPS; for that topic, see the script optimization with resmon guide.
Step 3: Fix database-related hitches
If you use oxmysql, add this line to server.cfg to see slow queries in the console:
# Prints queries that take longer than the given milliseconds to the console
set mysql_slow_query_warning 150If the warnings keep showing the same table, an index is usually missing. For example, in ESX, player vehicles are queried by the owner column:
-- See how the query runs
EXPLAIN SELECT * FROM owned_vehicles WHERE owner = 'char1:abc123';
-- Add the index if it is missing
CREATE INDEX idx_owned_vehicles_owner ON owned_vehicles (owner);Also migrate scripts that use the old mysql-async or ghmattimysql to oxmysql, and call queries asynchronously. For database setup and settings, see the oxmysql and MariaDB guide.
Step 4: Confirm a CPU-related hitch
If no single resource stands out in the profiler, warnings come even on an empty server, and every resource looks equally "slow," the problem is the CPU, not the code. Check on Linux:
# Look at the 'st' (steal) value on the %Cpu(s) line
top
# Load average and core count
uptime
nproc- High steal (st) value: the host is giving CPU time meant for your virtual server to other work.
- One core at 100 percent, others idle: the main thread is capped by the CPU's single-core power. You need faster cores, not more cores.
- All cores busy: a database, other servers or background jobs on the same machine are competing with FXServer.
We explain in detail why CPU choice matters so much in the best CPU for FiveM guide.
If your hardware is not enough
If the warnings continue after you have cleaned up the code and fixed the database, your server has outgrown its hardware. There are two paths:
- Move to a more powerful FiveM plan: the OB-FIVEM-5 FiveM server, with 6 CPUs and 12 GB DDR5 RAM, is sized to carry both the script and database load of busy roleplay servers.
- Move to your own VDS: if you want full control, root access and current-generation single-core performance, the Ryzen 9 9950X VDS plans, with AMD Ryzen 9 9950X processors, DDR5 RAM and KVM virtualization, give FXServer's main thread a strong foundation.
Keeping hitches from coming back
Fixing the problem once is not enough; every new script, every growing table and every added player can upset the balance again. For a lasting setup:
- Make changes one at a time. If you add five new scripts in one day, finding the one that causes hitches gets hard. Watch the console for an evening after each addition.
- Use a test server. Try major updates, framework upgrades and FXServer artifact changes in a copy environment first.
- Set up scheduled restarts. txAdmin's scheduled restart feature limits the impact of scripts that leak memory, but it does not fix the leak itself.
- Prune the database. Cleaning out characters that have not logged in for years, old log records and bloated tables shortens query times. Always take a backup before cleaning up.
- Keep a log. Noting the time of hitch warnings and the player count at that moment quickly reveals whether the problem is load-related or tied to a specific scheduled task.
Quick checklist
- Does the warning only appear at startup? If so, ignore it.
- Take a
profiler record 500when the warning appears and find the longest bar. - List slow queries with
mysql_slow_query_warningand add indexes. - Fix bulk saves and
Wait(0)loops. - Check steal and single-core usage with
top. - If all of that is clean, scale up your hardware.
Next step
A large share of persistent hitch problems comes from a growing server running on hardware that stayed small. At OyunBulut, the OB-FIVEM-5 plan for those who want the convenience of a game panel and the Ryzen 9 9950X VDS options for those who want OS-level control are hosted in Istanbul with DDoS protection. If you open a support ticket with your profiler output, we can work out together which option suits you.
Frequently asked questions
Does a server thread hitch warning harm the server?
The warning itself does no harm; it reports that the main thread stalled. But if it repeats often, players experience lag, teleporting vehicles and slow-responding menus.
Are hitch warnings during server startup normal?
Yes. Seeing a few warnings at startup is normal because hundreds of resources and files are loading. The problem is warnings that keep repeating during gameplay.
How do I find which script is causing hitches?
When warnings are frequent, run profiler record 500 and then profiler view in the console. The longest bars on the timeline show the problem resource.
Will adding RAM fix the hitch warning?
Usually not. Hitches are about CPU time; RAM only contributes when memory runs out and the system falls back to swap. If your code and database are clean, a faster CPU is the real fix.
How is it different from network thread hitch warning?
The server thread warning means the main thread that runs scripts and game logic stalled. The network thread warning is about the network thread and usually points to network or host-side problems.