I would like to run a program remotely (through ssh) but with audio going to the remote machine where the program actually runs. This would normally work with ALSA, but pulseaudio apparently checks some session authenticator before allowing connection from a client.

How to make this check less strict?

local: $ ssh remote           # remote is running pulseaudio and has sound hardware

remote:$ paplay something.wav
Connection failure: Connection refused

pa_context_connect() failed: Connection refused
remote:$ audacious something.mp3 # opens on local's X11 display
pulseaudio: Failed to connect to server: Connection refused
pulseaudio: Failed to connect to server: Connection refused
  • Check Hans answer for an update. pax11publish -r works on my Ubuntu 19.10. Feb 17, 2020 at 14:30

2 Answers 2


In my case, the following worked for me:

pax11publish -r
  • 1
    Other answer is outdated, use this. Worked well for me.
    – emk2203
    Feb 10, 2021 at 11:10

The culprit is that ssh does not set DBUS_SESSION_BUS_ADDRESS which is used to connect to Pulseaudio. A solution (based on this post) was to add the following lines to my ~/.bashrc, which are used when connecting over ssh:

if [[ -n $SSH_CLIENT ]]; then
    export DBUS_SESSION_BUS_ADDRESS=`cat /proc/$(pidof nautilus)/environ | tr '\0' '\n' | grep DBUS_SESSION_BUS_ADDRESS | cut -d '=' -f2-`

it uses the PID of nautilus (you may need to change that so to get some process which is always run in the session) and searches its environment variables for DBUS_SESSION_BUS_ADDRESS and exports it.

This make programs connecting to Pulse run fine. Other programs communicating over the session d-bus work as well (like audtool for driving audacious over command-line).

  • On Ubuntu 16.04, the command must be export DBUS_SESSION_BUS_ADDRESS=$(sudo cat /proc/$(pidof nautilus | cut -f1 -d" ")/environ | tr '\0' '\n' | grep DBUS_SESSION_BUS_ADDRESS | cut -d '=' -f2-) since pidof returns both processid and parent processid. But in my case, this solution does not work; I still suffer from the connection refused problem. Mar 31, 2018 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.