1

I broke my sound somehow. Whenever I try to play any sound (e.g. using sox), I get:

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

play FAIL sox: Sorry, there is no default audio device configured

My understanding is that WSLg should support sound forwarding using pulseaudio.

Note:

  • I'm on Ubuntu 22.04.1

  • It used to work before a (windows) reboot, I don't know what changed

  • X11 forwarding works fine

  • pulseaudio returns:

    W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
    E: [pulseaudio] core-util.c: XDG_RUNTIME_DIR (/mnt/wslg/runtime-dir) is not owned by us (uid 0), but by uid 1000! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.)
    

    Due to the fact that I'm always root; since that was the default behavior of of the distroy I'm using, I assumed this is ok.

  • alsa-reload returns

    Unloading ALSA sound driver modules: (none loaded).
    Loading ALSA sound driver modules: (none to reload).
    

    Not sure if that's supposed to happen.

2 Answers 2

1

Here is one way to resolve Connection failure: Connection refused issue:

  1. Add below to ~/.bashrc:
export HOST_IP="$(ip route |awk '/^default/{print $3}')"
export PULSE_SERVER="tcp:$HOST_IP"
  1. Run source ~/.bashrc.
  2. Edit etc/pulse/default.pa and etc/pulse/daemon.conf files as stated here.
  3. From the Command Prompt run pulseaudio.exe.
  4. Open Windows Defender Firewall control panel.
  5. Go to Advanced settings.
  6. Select Inbound Rules.
  7. Double click on the pulseaudio application.
  8. Click on Allow the connection action.
  9. Click OK.
0

I cannot claim that I understand what's going on, but my impression is that this problem appears when the sound settings are changed on the Windows side after WSL has been started.

In any case, sound comes back for me when I log out from WSL, shut it down with wsl --shutdown and then start WSL anew.

1
  • Thanks for the answer! I noticed that too... very annoying tho if you're developing :/ switched to Ubuntu for now
    – Nearoo
    Jan 22, 2023 at 23:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .