# How to set up a remote game-streaming server for Moonlight

A game-streaming server allows you to start a game instance on a dedicated machine and play it from other client devices. Such configuration can help overcome operating system and hardware limitations and enjoy various games on devices that can’t run them natively.

[Sunshine](https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/overview.html) <img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FvrZ5VWRYa1cmljBVIcXR%2Fsunshine.svg?alt=media&#x26;token=4eba68d1-9ef2-4e47-9180-cde6e1cc5ca7" alt="" data-size="line"> is an open-source solution that allows you to transform your device into a dedicated game server. It's easy to set up and doesn't require permanent changes to your system. Sunshine is designed to work as a host for the [Moonlight](https://github.com/moonlight-stream/moonlight-docs/wiki) <img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2Fd3d7H9lKtPGSUQmZTJdG%2Fmoonlight.svg?alt=media&#x26;token=7aca9551-8832-4c77-89c2-ad84a216590a" alt="" data-size="line"> game-streaming client.

While the app combination can be used hassle-free on the [local area network](https://nordvpn.com/blog/what-is-lan/) (LAN), the remote gaming option is available only by configuring [port forwarding](https://nordvpn.com/blog/port-forwarding/) or complicated network setups. By supplementing the game-streaming setup with [Meshnet](https://nordvpn.com/meshnet/), you can easily connect your remote devices to a single network and enjoy your games over a fast and encrypted network tunnel.

For a quick visual overview, check out the video below:

{% embed url="<https://www.youtube.com/watch?v=s9nCay84r4I>" %}

If you prefer a text-based approach, follow the written instructions that explain how you can turn your device into a [VPN gaming server](https://nordvpn.com/gaming/) using Sunshine and play remotely using the Moonlight client.

## Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Make sure that your server’s hardware and software fit the [system requirements](https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/overview.html#system-requirements) provided on the Sunshine documentation page.

## Configure the Sunshine server <a href="#configure-the-sunshine-server" id="configure-the-sunshine-server"></a>

Start your setup process by configuring the Sunshine server.

### Installing Sunshine <a href="#installing-sunshine" id="installing-sunshine"></a>

Begin by installing Sunshine on the machine that will function as your game server.

{% tabs %}
{% tab title="Windows" %}

1. Visit the [Releases page](https://github.com/LizardByte/Sunshine/releases/) of the Sunshine GitHub repository.
2. Download the Windows installer file for the latest available version.

   <div align="left"><figure><picture><source srcset="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FSXxNOO2Vri7Wkkjvvmpw%2Fsunshine_dl_win_dark.png?alt=media&#x26;token=96813efc-85a5-4874-90ca-c3474d57b743" media="(prefers-color-scheme: dark)"><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FP3jNRx7FoTFwXE8fA0bw%2Fsunshine_dl_win.png?alt=media&#x26;token=e3f2db4d-2a5f-42f2-bf51-1acf280d0a59" alt="Downloading the Sunshine windows installer file from GitHub."></picture><figcaption></figcaption></figure></div>

   &#x20;
3. Launch the downloaded file. If the Microsoft Defender SmartScreen window shows up, select **More info** and click **Run anyway**.
4. Follow the instructions presented by the installation wizard.
5. Click **Finish** to complete the process and close the installer window.
   {% endtab %}

{% tab title="macOS" %}
{% hint style="info" %}
**Note**

Sunshine on macOS is still in its experimental stage. For this reason, some features may not be available.
{% endhint %}

To install Sunshine on macOS, you can use the [Homebrew](https://brew.sh/) package manager.

1. Open **Terminal**.
2. Enter the following command to install Homebrew:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
   </code></pre>

   &#x20;\
   For additional information about the installation process, refer to [Homebrew documentation](https://docs.brew.sh/Installation).
3. Follow the on-screen instructions to finish the installation.
4. Run the two commands below to add the Sunshine repository and install the Sunshine package.\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">brew tap LizardByte/homebrew
   brew install sunshine
   </code></pre>

{% endtab %}

{% tab title="Linux" %}
{% hint style="info" %}
**Note**

In this article, the Ubuntu 22.04.1 LTS Linux distribution is used as an example.
{% endhint %}

1. Visit the [Releases page](https://github.com/LizardByte/Sunshine/releases/) of the Sunshine GitHub repository.
2. Download the latest package for your Linux distribution and system architecture.

   <div align="left"><figure><picture><source srcset="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FlAt4Uo1LMZyhxVRqU60q%2Fsunshine_dl_linux_dark.png?alt=media&#x26;token=d2c797f4-dd64-4e7b-8e31-c62d3ead05f1" media="(prefers-color-scheme: dark)"><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FJ3c0vENCf30d7Xc8qz2Z%2Fsunshine_dl_linux.png?alt=media&#x26;token=7be5d412-2197-4deb-ab57-5d9ee2e95790" alt="Downloading the Sunshine package for Ubuntu 22.04 from GitHub."></picture><figcaption></figcaption></figure></div>

   &#x20;
3. Open **Terminal** and navigate to the downloaded file’s location using the `cd` command.\
   &#x20;\
   **Example**

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">cd ~/Downloads
   </code></pre>

   &#x20;&#x20;
4. Install the Sunshine package and its required dependencies by running the following command:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sudo apt install -f ./sunshine* -y
   </code></pre>

   &#x20;&#x20;
5. Check whether Sunshine is installed properly with this command:\
   &#x20;

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">sunshine --version
   </code></pre>

   &#x20;

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FbAlJA14CccYWxQbGSLBo%2Fsunshine_version_linux.png?alt=media&#x26;token=f2ba94ca-e0bc-42a1-8fba-574b93c37b22" alt="Terminal output showing the version of Sunshine."><figcaption></figcaption></figure></div>

{% hint style="success" %}
**Tip**

If you install Ubuntu `.deb` package, you may receive the following error message when trying to interact with Sunshine:

{% code overflow="wrap" %}

```
sunshine: error while loading shared libraries: libboost_chrono.so.1.74.0: cannot open shared object file: No such file or directory
```

{% endcode %}

To resolve this problem, install the [libboost-chrono1.74.0](https://packages.ubuntu.com/jammy/libboost-chrono1.74.0) package with this command:

{% code overflow="wrap" %}

```bash
sudo apt install libboost-chrono1.74.0
```

{% endcode %}
{% endhint %}
{% endtab %}
{% endtabs %}

### Starting Sunshine <a href="#starting-sunshine" id="starting-sunshine"></a>

After installing Sunshine, you need to initialize the server app and access its web user interface (UI), where all of the settings are located.

{% tabs %}
{% tab title="Windows" %}

1. Launch **Sunshine**. It will open the `https://localhost:47990/` URL in your default internet browser.
2. Enter your preferred Sunshine username and password and click **Login**.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FEp78xOJnrAU7hj7tIiq3%2Fsunshine_win_web_login.png?alt=media&#x26;token=6ab9ef7a-69fc-4e91-8d99-cd73124237f3" alt="Entering username and password in the Sunshine web UI."><figcaption></figcaption></figure></div>

   &#x20;
3. Once the page reloads, log in using your newly created account credentials.

{% hint style="info" %}
**Note**

You may see a “Your connection is not private” message because Sunshine is using a self-signed [SSL certificate](https://nordvpn.com/blog/what-is-ssl/). To proceed further, click **Advanced** > **Proceed to localhost (unsafe)**.
{% endhint %}
{% endtab %}

{% tab title="macOS" %}

1. Open **Terminal**.
2. Run the `sunshine` command to initialize Sunshine and automatically launch it at system startup. During the process, you will be asked to grant system permissions — make sure to allow them.
3. Open your internet browser and visit the following URL:\
   `https://localhost:47990/`\
   &#x20;
4. Enter your preferred Sunshine username and password and click **Login**.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F3ZHzl0KmuGoN4oYtiOWD%2Fsunshine_mac_web_login.png?alt=media&#x26;token=acce80cc-7fdc-4402-aec8-934c04ae496a" alt="Entering username and password in the Sunshine web UI."><figcaption></figcaption></figure></div>

   &#x20;
5. Once the page reloads, log in using your newly created account credentials.

{% hint style="info" %}
**Note**

You may see a “Your connection is not private” message because Sunshine is using a self-signed [SSL certificate](https://nordvpn.com/blog/what-is-ssl/). To proceed further, click **Show details** > **visit this website**.
{% endhint %}
{% endtab %}

{% tab title="Linux" %}

1. Open **Terminal**.
2. Run the `sunshine` command to initialize Sunshine.\
   &#x20;\
   Once Sunshine is ready, you should see this output in your command line window:

   <pre class="language-bash" data-overflow="wrap"><code class="lang-bash">Info: Configuration UI available at [https://localhost:47990]
   </code></pre>

   &#x20;
3. Open your internet browser and visit the following URL:\
   `https://localhost:47990/`\
   &#x20;
4. Enter your preferred Sunshine username and password and click **Login**.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FVUMPGlQrGibGpLP3hBv1%2Fsunshine_linux_web_login.png?alt=media&#x26;token=49812df9-46fa-4130-8a75-fd8c673448e9" alt="Entering username and password in the Sunshine web UI."><figcaption></figcaption></figure></div>

   &#x20;
5. Once the page reloads, log in using your newly created account credentials.

{% hint style="info" %}
**Note**

You may see a “Your connection is not private” message because Sunshine is using a self-signed [SSL certificate](https://nordvpn.com/blog/what-is-ssl/). To proceed further, click **Advanced** > **Accept the risk and continue**.
{% endhint %}
{% endtab %}
{% endtabs %}

### Importing games <a href="#importing-games" id="importing-games"></a>

Once you access the Sunshine web UI, you can import the games you want to play on other remote devices. The steps may vary slightly depending on the OS you use and the games you want to add. For this example, a game from Steam on Windows will be imported to the Sunshine library.

1. On the Sunshine web interface, select the **Applications** section.
2. Click **Add new**.
3. Fill in the following fields:
   * In the **Application name** field, type in the name of the game you want to import.
   * In the **Command** field, enter a command to initialize the game’s executable file.
     * For Windows: `cmd /c <file_name.exe>`
     * For macOS and Linux: `<file_name>`
   * In the **Working directory** field, enter the path of the game’s folder on your system.\
     &#x20;\
     **Example**

     <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FOMZ97wFEX0PzVqD5RnnT%2Fsunshine_add_game.png?alt=media&#x26;token=5a30571f-32ee-45cb-b0f3-549715407c83" alt="Filled in Application name, Command, and Working directory fields with the game&#x27;s information on Sunshine web UI."><figcaption></figcaption></figure></div>

     &#x20;
4. Click **Save**.

The game is now added to your Sunshine server library, and client devices will be able to play it remotely .

{% hint style="info" %}
**Note**

You can find more detailed guidelines for adding games and apps to your server’s library on the [Sunshine documentation](https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/guides/app_examples.html) page.
{% endhint %}

## Set up the Moonlight client <a href="#set-up-the-moonlight-client" id="set-up-the-moonlight-client"></a>

Once the Sunshine server is running and you have added your desired games, you can install the Moonlight game-streaming client on all devices connecting to the server.

### Installing Moonlight <a href="#installing-moonlight" id="installing-moonlight"></a>

On devices running desktop operating systems, you can get the Moonlight client installer files from the “Downloads” section of the [Moonlight PC GitHub repository](https://github.com/moonlight-stream/moonlight-qt#downloads).

On mobile devices, you can download the Moonlight client from the following sources:

* On Android, you can install Moonlight from the [Google Play Store](https://play.google.com/store/apps/details?id=com.limelight) or the [Moonlight for Android](https://github.com/moonlight-stream/moonlight-android) GitHub repository.
* On iOS, you can install Moonlight from the [App Store](https://apps.apple.com/us/app/moonlight-game-streaming/id1000551566).

### Pairing with the Sunshine server <a href="#pairing-with-the-sunshine-server" id="pairing-with-the-sunshine-server"></a>

To establish a connection between your Sunshine server and the Moonlight client, you need to pair the devices. While Moonlight automatically scans for servers in your LAN, you need to manually add your remote Meshnet server.

1. Open **Moonlight**.
2. In the upper-right corner, select the computer icon. Alternatively, you can press **Ctrl** + **N** on your keyboard.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2F3m5DPfc05K1MltlQPRGN%2Fmoonlight_add_pc_manually.png?alt=media&#x26;token=a122d202-eabd-40a6-a6ba-ee57bf14c7fc" alt="Clicking &#x27;Add PC manually&#x27; in Moonlight."><figcaption></figcaption></figure></div>

   &#x20;
3. In the new dialog, enter the Nord name of your Sunshine server and click **OK**.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FQL2IT2lvu5q6D4gJ0a4K%2Fmoonlight_remote_IP.png?alt=media&#x26;token=5a7cc321-d00b-4290-a333-97404f7cc51d" alt="Entering the Nord name of the Sunshine server and clicking &#x27;OK&#x27;."><figcaption></figcaption></figure></div>

   &#x20;
4. Select the newly added device’s icon in the Moonlight window. Upon clicking the server’s icon, you will be shown a PIN code.
5. Open the Sunshine web interface and select **PIN** at the top.
6. Enter the PIN code prompted on your client device and click **Send**.

You should see a green success message indicating that pairing was successful.

## Play games remotely over Meshnet <a href="#play-games-remotely-over-meshnet" id="play-games-remotely-over-meshnet"></a>

After successful pairing, you can start playing games from your server’s library on other devices remotely.

1. In **Moonlight**, select your Sunshine server.

   <div align="left"><figure><img src="https://3559400189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0cTezbT2vN0lurEio8Z5%2Fuploads%2FLz8duWFtCDz7BmCR8UbF%2Fmoonlight_select_pc.png?alt=media&#x26;token=985a22da-442f-46b4-be7a-dde916b05c65" alt="Selecting the newly added Sunshine server in Moonlight." width="563"><figcaption></figcaption></figure></div>

   &#x20;
2. From the list of available games, select the one you want to play.

The game will shortly load, and you’ll be able to enjoy your remote gaming session!

{% hint style="success" %}
**Tip**

You can use the Moonlight settings menu to change the streaming resolution and bitrate to optimize the game-streaming quality for your setup.
{% endhint %}
