Headless Unity server on Linux (VirtualBox)

Quick tutorial

Install Linux on VirtualBox

Best if you use the same Linux distribution that you can later use also with the Amazon Cloud (AWS), so I recommend Ubuntu Server 14.04 LTS.

Install the Linux on VM, all settings set to default. Remember to select SSH server package if possible, if not install it separately with

sudo apt-get install openssh-server

The SSH server should run automatically on system start.

Forward ports

In you VM go into Settings -> Network -> Advanced and forward the ports as in the picture:


Setup SSH connection to the VM

Install WinSCP and create a new session (see pic. below).


Create server build

Create server scene

Create a scene that will be run by the server. Add NetworkManager and configure it as in the picture. The Level1 here is the gameplay scene.


Create script to auto-start the server

Create and attach this script to the same GameObject as the NetworkManager.

public sealed class AutoServer : MonoBehaviour {

        private NetworkManager networkManager;

        private void OnEnable()
            Assert.IsNotNull(networkManager, "NetworkManager component is not set!");

        private void Start() {

Create client scene

Create scene for gameplay. Add NetworkManager and NetworkManagerHUD. Set the Online Scene, ip to localhost and port to 7777.

Build the server

In the Build Settings add the server scene as the first one and the gameplay scene. Also select the headless option.


Build the client

Just a normal PC client.

Run the server

Copy server build to the VM using WinSCP. On the VM go to the build directory and execute

chmod +x <executableFile>

to make it executable. Then run the game server with


You should see something like this:


If it says sth. about missing file then probably your build’s architecture and the of VM doesn’t match. For me both are 64 bit.

Also, you can check the game server log for errors. You’ll find it in ~/.config/unity3d. It can be also specified with the -logfle <filename.txt> argument

Connect the client

Run the client, click the LAN Client button. It should connect.

I wrote this tutorial from memory so it might be missing things. If something doesn’t work for you, just post a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s