Set Up Sunshine on Windows 11 for Moonlight
TL;DR
Sunshine on a Windows 11 PC lets Moonlight play that PC's games somewhere else on your network. Install Sunshine, set a strong web password, and pair with a PIN. This page is the PC. Handheld client setup is in the AYN Thor guide.
What you need
- A Windows 11 PC with an NVIDIA, AMD, or Intel GPU, and an administrator account.
- A monitor plugged into the GPU you want to capture, or an HDMI dummy plug on that GPU. The capture follows the screen attached to that GPU.
- Moonlight on the device you play on. Handheld taps, the resolution list, and the bitrate slider are in the AYN Thor guide.
- The PC on Ethernet. The client can be on Ethernet or on 5 GHz Wi-Fi.
Install Steam on the host when you want Steam Big Picture. Other games can be added on their own.
Install Sunshine
- Open the Sunshine releases page and download the current Windows installer. On an Intel or AMD PC, use the 64-bit
.msi. Uninstall an older copy that was not installed from an MSI before you run the new one. - Run the installer. Leave the service and the firewall parts selected. The service is what keeps Sunshine running in the background. Do not start a second copy next to it.
- If Windows asks which networks to allow, choose private networks.
- Reboot once when you are done. A controller often needs that reboot before it shows up in a stream.
Confirm the service from an administrator Command Prompt if the tray icon never appears:
sc.exe query SunshineService
You want the state to read RUNNING.
Set the web password
- Right-click the tray icon and choose Open Sunshine, or open
https://localhost:47990in a browser on the PC. - The browser warns that the certificate is not trusted. Sunshine uses a self-signed certificate. Continue, on this PC, to the page you just installed.
- The first launch asks for a username and a password. Use a long password that you do not use for anything else, and save both somewhere you can look them up. If you lose them, reset them with the command at the end of this page.
- Sign in when the page asks you to.
Anyone who can open this page and sign in can pair a new client that reaches the PC. That is the whole reason the password exists.
Stay safe
- Use a long, unique password on the Sunshine web page. Anyone who can sign in can pair a new client to the PC. - Do not port-forward port 47990 or the streaming ports, and do not turn on UPnP. Opening those ports publishes the PC past your home network. - For play away from home, put both the PC and the client on a VPN. Pair them on the home LAN first. {% include proton-affiliate-link.html offer_key="proton_vpn_offer_id" label="Proton VPN" %} is one WireGuard or OpenVPN option.
Leave UPnP off under Configuration, then Network. UPnP asks the router to publish the stream. The web page should stay reachable from your LAN only.
Pair a client
- Install Moonlight on the client and join it to the same network as the PC. For a handheld, follow the AYN Thor guide from the client install onward.
- Moonlight should list the PC after a few seconds. If it does not, add the PC by its LAN address.
192.0.2.50is only the shape of an address. Use the IPv4 address fromipconfigon the host, from the Ethernet adapter when there is a cable. - Select the PC. Moonlight shows a PIN.
- On the host, open PIN in the Sunshine page, type the PIN, type a device name, and submit.
- You should get a success message. Then start an app from Moonlight.
Sunshine already lists Desktop and Steam Big Picture. Start Desktop first when Windows is locked, sign in, and then start the game or Big Picture. A program that exits immediately ends the stream. Add other games under Applications. Restart Moonlight if a new entry does not show up.
Two live network adapters on the host are a common reason the PC never appears. Unplug the slower one, or disconnect Wi-Fi when Ethernet is already up. Turn a VPN off for the at-home test, including a switch that blocks the local network. Turn it back on when you leave the house.
Picture and the encoder
Set the first stream in the client, not in a pile of host toggles.
- Start at 1080p and 60 FPS. Move up only after a session looks smooth.
- Leave the bitrate alone for a first test on a wire. If the picture stutters, lower the bitrate, then try 720p.
- On the host, leave the encoder on automatic. Pin NVIDIA, Intel, or AMD only when automatic fails, and only for the GPU the display is plugged into. Software encoding uses the CPU and is the slow fallback.
A PC with no monitor needs a dummy plug on the GPU you want to encode with. Keep that display awake during the stream. On a desktop Moonlight window, Ctrl+Alt+Shift+Q quits the stream and leaves the game running.
If it doesn't work
- The PC is missing, or the web page will not open from a second computer on the LAN. Confirm
SunshineServiceis running, the client is on the same network, and only one adapter on the host is active. Allow Sunshine on private networks. - A LAN client still cannot connect after that. From an administrator prompt, add these firewall rules:
netsh advfirewall firewall add rule name="GameStream UDP" dir=in protocol=udp localport=5353,47998-48010 action=allow
netsh advfirewall firewall add rule name="GameStream TCP" dir=in protocol=tcp localport=47984,47989,48010 action=allow
- Pairing failed, or nothing is waiting to pair. Start the pairing attempt in Moonlight again and type the new PIN.
- Black screen, or a tiny picture in the corner. Wake the monitor on the capture GPU, or fit a dummy plug. Start Desktop and sign in if Windows is still locked.
- The stream stutters. Use Ethernet on the PC, 5 GHz or a wire on the client, and a lower bitrate. 720p at 30 FPS is the fallback while you test the link.
- You forgot the web password. From an administrator Command Prompt, stop the service, set a new username and password, and start the service. Replace
USERandPASS.
sc.exe stop SunshineService
cd /d "%ProgramFiles%\Sunshine"
.\sunshine.exe --creds USER PASS
sc.exe start SunshineService
Uninstall from Windows Settings, then Apps. Remove the two GameStream rules first if you added them:
netsh advfirewall firewall delete rule name="GameStream UDP"
netsh advfirewall firewall delete rule name="GameStream TCP"