Tech

Fixing No Audio in Moonlight (Sunshine Host) on Ubuntu

Audiowave on a Desktop and a Laptop next to it with the text Moonlight and Ubuntu displayed on the screen

Fixing No Audio in Moonlight (Sunshine Host) on Ubuntu

When setting up Sunshine and Moonlight for remote access on Ubuntu, you might notice that everything works perfectly—except for the sound. This is a common issue when running Ubuntu in a headless setup or via a HDMI dummy plug.


The Issue

By default, Sunshine runs as a system service. This means it doesn’t have access to your user’s audio session (either PulseAudio or PipeWire). As a result, even though Ubuntu can play sound locally, Sunshine can’t capture and forward that audio to Moonlight.

That’s why you might find that NoMachine (remote desktop app) streams audio just fine (since it runs within your user session), while Sunshine doesn’t.


The Fix

The solution is to give Sunshine access to your user’s audio environment by editing its systemd configuration file and specifying the correct Environment variables.

1. Install PulseAudio Utilities

sudo apt install pulseaudio-utils

This installs the pactl command, which lets you check and manage your audio devices.

2. Identify Your Audio Devices

pactl list short sinks

You’ll see something like:

120  alsa_output.usb-CSCTEK_USB_Audio_and_HID_A34004801402-00.iec958-stereo  PipeWire  s16le 2ch 48000Hz  SUSPENDED
425  alsa_output.pci-0000_00_1f.3.hdmi-stereo                              PipeWire  s32le 2ch 48000Hz  SUSPENDED

That means your audio system is using PipeWire (modern default for Ubuntu 24.04+).


3. Edit the Sunshine Service

Next, we’ll tell Sunshine to use your user’s audio session instead of running silently in the background.

sudo systemctl edit sunshine

Paste the following lines (replace 1000 with your user ID if different — check with echo $UID):

[Service]
Environment="XDG_RUNTIME_DIR=/run/user/1000"
Environment="PIPEWIRE_RUNTIME_DIR=/run/user/1000"
Environment="PULSE_SERVER=unix:/run/user/1000/pulse/native"

Save and exit the editor, then reload and restart the service:

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl restart sunshine

4. Test Audio in Moonlight

Now reconnect with Moonlight—if everything is configured correctly, you should hear your Ubuntu system audio perfectly through your remote device.

If you’d like to test locally first, try this:

paplay /usr/share/sounds/alsa/Front_Center.wav

If you hear sound, Sunshine should now successfully capture it.


5. Optional: Create a Virtual Audio Device (Headless Mode)

If your PC runs without a monitor or HDMI dummy, you can create a virtual audio output so Sunshine always has something to capture:

pactl load-module module-null-sink sink_name=VirtualOutput sink_properties=device.description=VirtualOutput
pactl set-default-sink VirtualOutput
sudo systemctl restart sunshine

This ensures that audio streaming continues to work even in a fully headless setup.


Summary

  • Sunshine’s no-audio issue happens because it runs outside the user’s audio session.
  • Adding environment variables in the systemd service fixes this.
  • PipeWire users are fully supported once those variables are set.
  • A virtual audio sink is a good fallback for headless servers.

After applying these steps, you’ll have smooth, high-quality audio streaming over Moonlight—making your remote Ubuntu setup feel almost identical to being right in front of it.

Leave a reply

Loading comments…