Getting sound to work on WSL2

I’ve been trying to get sound to work. It’s challenging for the same reasons listed in the graphical case (no localhost/ available)

I got it working following the wiki steps but with some tweaks

the ‘auth-ip-acl=’ parameter needs to use the IP from the WSL instance though (‘ip a’ on the WSL command line to get it)
(unfortunately the WSL IP change after a reboot so the config needs to be re-edited…)

  • start bin/pulseaudio

  • Disable Windows Defender Firewall for Guest or public Network (a better way would be to add firewall rules to allow only what is needed but I didn’t figure out how to do that yet, help welcome if anyone knows?)

  • in WSL

    • install libpulse0 if you don’t have it yet
    • export the environmenet
$ export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}');

Sound should be working then!


Re the ‘auth-ip-acl=’ parameter needs to use the IP from the WSL instance though.

I have edited my file to include acl auth-ip-acl= because WSL2 seems to choose any random address from this range. The only issue with this is that you may get other machines behind your router trying to send pulseaudio sound packets to your computer???

I can’t make it work, been trying for 2 days. I have tried everything but no sound.
Windows ver. 2004 (build 19041.84), WSL2.

For me work the configurations as described above, but with a change:
in pulseaudio configuration in the file the line is
load-module module-native-protocol-tcp auth-anonymous=1

works fine on windows 10 build 2004 / wsl2 / ubuntu 20.4