Sunshine + Moonlight: Self-Hosted Game Streaming for Your Homelab
GeForce Now and Xbox Cloud Gaming stream games from data centers. But if you have a gaming PC sitting at home, you can stream directly from it — to a TV in another room, a laptop, a Steam Deck, or a phone — using Sunshine and Moonlight.
Photo by Michael Förtsch on Unsplash
Sunshine is an open-source implementation of NVIDIA's GameStream protocol. You run it on your gaming PC. Moonlight is the client that connects to it. Together they give you low-latency, high-quality game streaming with no subscription fees and no cloud middleman.
Why Sunshine + Moonlight Instead of Parsec or Steam Link?
| Solution | Latency | Quality | Remote Access | Cost | Open Source |
|---|---|---|---|---|---|
| Sunshine + Moonlight | Very low | 4K 120fps | Yes | Free | Yes |
| Steam Link | Low | 4K 60fps | Limited | Free | No |
| Parsec | Low | Up to 4K | Yes | Free/paid | No |
| GeForce Experience GameStream | Low | 4K | Yes (deprecated) | Free | No |
NVIDIA deprecated their GameStream protocol. Sunshine picked up the torch and improved it — adding support for AMD and Intel GPUs, Linux hosting, HDR, and 4K 120fps.
Hardware Requirements
Host (streaming server):
- Any modern GPU: NVIDIA (recommended), AMD, or Intel Arc
- 8GB+ RAM
- Windows 10/11, Linux, or macOS
- Wired ethernet strongly recommended for best quality
Client (where you stream to):
- Any device running the Moonlight app: Windows, macOS, Linux, Android, iOS, tvOS, or Raspberry Pi
- Wired or 5GHz WiFi (WiFi works but adds latency)
Installing Sunshine on Windows
Download the installer from the Sunshine releases page and run it.
After installation, Sunshine starts automatically and opens a web interface at https://localhost:47990.
First-time configuration:
- Set a username and password (required on first access)
- Configure the encoder: Go to Configuration → Encoder
- NVIDIA: Select
nvenc(hardware encoder — lowest CPU overhead) - AMD: Select
amf - Intel: Select
quicksync - Software fallback:
libx264(uses CPU — higher overhead)
- NVIDIA: Select
- Set resolution and framerate: 1080p/60fps for most use cases, 4K/60fps if your GPU and network support it
Like what you're reading? Subscribe to HomeLab Starter — free weekly guides in your inbox.
Installing Sunshine on Linux
For Ubuntu/Debian:
# Download the appropriate .deb from GitHub releases
wget https://github.com/LizardByte/Sunshine/releases/latest/download/sunshine-ubuntu-22.04.deb
sudo apt install ./sunshine-ubuntu-22.04.deb
For Arch Linux:
yay -S sunshine
Sunshine on Linux requires access to the display server. For X11:
# Add udev rules for input capture
echo 'KERNEL=="uinput", SUBSYSTEM=="misc", OPTIONS+="static_node=uinput", TAG+="uaccess"' | \
sudo tee /etc/udev/rules.d/85-sunshine.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
For Wayland (experimental), some input capture features are limited.
Connecting with Moonlight
- Install Moonlight on your client device (available on all platforms)
- Launch Moonlight — it will auto-discover Sunshine hosts on the same network
- Click your host → you'll be shown a PIN
- Enter the PIN in Sunshine's web UI (Clients tab → Pair)
- Start streaming
For remote access (outside your home network), you'll need port forwarding or Tailscale (see below).
Adding Applications and Games
Sunshine's web UI lets you add any application as a streamable target:
- Go to Applications → Add New
- Set:
- Application Name: What shows up in Moonlight
- Command: The executable path (e.g.,
C:\Program Files\Steam\steam.exe) - Working Directory: Usually the same as the command path
- Optional: Set a cover image for the Moonlight grid
Pre-configured apps usually include Desktop (streams the full desktop) and any games Sunshine detects.
To stream Steam games, add Steam as an application and launch games through Steam's Big Picture mode, or add individual games directly.
Performance Optimization
Bit rate: The most important setting. Start at 20 Mbps for 1080p/60fps. For 4K/60fps, 50–80 Mbps. Reduce if you see packet loss.
Encoder preset: In Configuration → Encoder:
p1(faster, lower quality) top7(slower, higher quality)- For live streaming,
p4orp5is a good balance - If CPU or GPU is maxed, drop to
p2orp3
Color mode:
- SDR: Works everywhere, simpler
- HDR: Requires HDR TV/monitor on client and host, and Moonlight with HDR support
Audio: Sunshine supports 5.1 and 7.1 surround passthrough if your setup supports it.
Remote Access with Tailscale
To stream outside your home network without port forwarding:
- Install Tailscale on both the host (Sunshine) and client (Moonlight) machines
- Both devices will get Tailscale IPs (e.g.,
100.64.x.x) - In Moonlight, add the host manually using the Tailscale IP
Tailscale's WireGuard-based tunnel provides secure, low-overhead connectivity. Latency will increase for remote connections, but for typing tasks and slow-paced games it works well. Fast-paced gaming generally needs a low-latency local connection or fiber-grade internet.
Port Forwarding (Alternative to Tailscale)
If you prefer direct port forwarding:
| Protocol | Port | Purpose |
|---|---|---|
| TCP | 47984 | Control stream |
| TCP | 47989 | HTTPS management |
| UDP | 47998 | Video stream |
| UDP | 47999 | Audio stream |
| UDP | 48000 | Video stream (alt) |
| UDP | 48010 | Video stream (alt) |
Forward these ports on your router to the Sunshine host. Use a DDNS service if your public IP is dynamic.
Sunshine as a Remote Desktop
Sunshine isn't just for gaming. It works excellently as a general remote desktop:
- Add Desktop as an application in Sunshine
- Connect with Moonlight for full desktop access
- Lower latency than most RDP solutions for graphical work
- Works great for accessing a PC from a tablet or TV
For text-heavy remote work, any solution works. For anything graphical (video editing, design, 3D work), Sunshine + Moonlight's hardware-encoded stream is noticeably smoother than RDP.
Common Issues
Black screen on connect: Usually means Sunshine can't capture the display. Check that a monitor (real or virtual) is attached to the GPU. Use a HDMI dummy plug if the host has no monitor.
High latency: First check ethernet vs WiFi. Then reduce bitrate. Then check encoder — software encoding (libx264) is much higher latency than hardware.
Pairing fails: Ensure Windows Firewall allows Sunshine through (the installer usually handles this). On Linux, check that ports aren't blocked by UFW.
Low frame rate on client: Increase bitrate, ensure the client network is fast enough. Check host GPU usage — if it's pegged at 100%, reduce game quality settings.
Summary
Sunshine + Moonlight is the best self-hosted game streaming solution available. It delivers hardware-accelerated 4K streaming with sub-20ms latency on a local network, works with any GPU (not just NVIDIA), and streams to every major platform.
Set it up once, pair your devices, and you can play your gaming PC library from any room — or remotely with Tailscale.
