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/127.0.0.1 available)

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

the ‘auth-ip-acl=127.0.0.1’ 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!

2 Likes

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

I have edited my default.pa file to include acl auth-ip-acl=172.16.0.0/12 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.