The short answer
Unity builds a dedicated server as a sub-target of the desktop platforms. In Unity 6 you add a Linux Server build profile, switch to it and press Build. Unity strips audio, textures, meshes, shaders and rendering code that a headless server does not need, which cuts size, memory and CPU use. The output is a Linux x86-64 executable with a data folder.
Before you build
- Install the module. If the Linux Server platform is missing from the Platform Browser, choose Install with Unity Hub and add the Linux Dedicated Server module for your editor version.
- Separate server code from client code. Dedicated Server builds define the
UNITY_SERVERscripting symbol, so you can write#if UNITY_SERVERto start networking and skip UI, audio and input. - Use a fixed port and bind all interfaces. A server bound to
127.0.0.1is invisible to the world. - Plan for logs and exit codes. A server that quits silently is hard to diagnose. Log startup errors to standard output.
Build steps
- Open Build ProfilesIn the Unity Editor choose File > Build Profiles.
- Add the Linux Server platformSelect Add Build Profile to open the Platform Browser and choose Linux Server. If it is not listed, select Install with Unity Hub and add the module for your editor version.
- Switch to the profileSelect Switch Profile so the new profile becomes active. A Dedicated Server build is a headless executable with no graphical interface.
- Set server behavior in codeUse
#if UNITY_SERVERto start your networking in server mode, bind to0.0.0.0and a fixed port, and skip UI, audio and input setup. - BuildSelect Build and choose an empty output folder. Keep the whole folder, since the executable needs its data directory.
- Test on Linux and packRun it headless on Linux, join from another machine, set the executable bit, then archive the folder with
tar -czf server.tar.gz .with no symbolic links or secrets inside.
Test the build the way a host will run it
On a Linux x86-64 machine or container, extract the archive and run the server with the same arguments you will declare:
mkdir game && tar -xzf server.tar.gz -C game
chmod +x game/UnityServer.x86_64
./game/UnityServer.x86_64 -batchmode -nographics
In a second terminal check that the port is open (ss -lunp for UDP, ss -ltnp for TCP) and join with a client from another machine. If the server exits immediately, read its log; exit code 127 usually means a missing library or the wrong architecture, and 139 a crash inside the program.
Common mistakes
| Mistake | Symptom | Fix |
|---|---|---|
| Built the Windows server by accident | "No Linux x86-64 program found" | Check the profile says Linux Server and the file type is ELF 64-bit x86-64 |
Bound to 127.0.0.1 | Port open locally, unreachable remotely | Listen on 0.0.0.0 |
| Executable bit lost | Exit code 126 | chmod +x before packing |
| Secrets in the build | Upload rejected | Read tokens from environment variables |
| Server waits for a display or input | Hangs at startup | Guard with #if UNITY_SERVER or -batchmode |
| Built on a newer Linux than the host | The code reading holds the build for glibc | The worker image has glibc 2.39 (Ubuntu 24.04); build there or in an ubuntu:24.04 container |
| Declared Mirror or NGO for a game with its own sockets | A non-blocking advisory says no Mirror or Netcode assembly was found | Declare Custom native TCP/UDP (direct) and supply a join probe |
Next
Pick the networking page that matches you: Unity Mirror or Unity NGO, then use the ports and firewall checklist. If your server uses neither and speaks its own TCP or UDP protocol, read the custom native section of the manifest guide: a direct, limited lane where you supply the join probe.
Frequently asked questions
Can I build a Linux server from Windows?
Yes. Install the Linux Dedicated Server module for your editor version with Unity Hub, add the Linux Server profile in Build Profiles and build from your Windows machine. You still need a Linux machine or container to test it, because a build that starts on Windows tooling may fail on Linux libraries or permissions.
Sources
- Unity Manual: Build a Dedicated Server, accessed October 3, 2026
- Unity Manual: Dedicated Server introduction, accessed October 3, 2026