“Connection to pulseaudio failed” - and can't start-pulseaudio-x11 either

10,852

Solution 1

This solution is due to "wabbit" on #[email protected]

You probably have a file named

$HOME/.config/pulse/default.pa

remove it, and pulseaudio should either respawn itself, or you can start it with something like pactl info or just pulseaudio. When that happens, the pavucontrol volume control GUI should also work again.

To ensure the daemon is up, have a look at /var/log/syslog; you should lines such as:

Jan 29 00:56:34 myhostname pulseaudio[19553]: [pulseaudio] source.c: Default and alternate sample rates are the same.

and maybe

Jan 29 00:56:36 myhostname pulseaudio[19563]: [pulseaudio] pid.c: Daemon already running.

Solution 2

I encountered a similar issue, however I did not have a default.pa file.

I found the following steps worked. In terminal:

apt-get purge pulseaudio

Then, under

$HOME/.config

Delete the entire pulse folder.

Then reinstall pulseaudio:

apt-get install pulseaudio

When firing up, pulseaudio will complain it failed to 'open cookie file' if called from terminal, however it will recreate the entire folder structure. Running it again, it will resume normal operations with sound (hopefully) enabled.

Share:
10,852

Related videos on Youtube

einpoklum
Author by

einpoklum

Made my way from the Olympus of Complexity Theory, Probabilistic Combinatorics and Property Testing to the down-to-earth domain of Heterogeneous and GPU Computing, and now I'm hoping to bring the gospel of GPU and massive-regularized parallelism to DBMS architectures. I've post-doc'ed at the DB architecture group in CWI Amsterdam to do (some of) that. I subscribe to most of Michael Richter's critique of StackOverflow; you might want to take the time to read it. If you listen closely you can hear me muttering "Why am I not socratic again already?"

Updated on September 18, 2022

Comments

  • einpoklum
    einpoklum almost 2 years

    I'm using Devuan ASCII (~= Debian Stretch). Audio seems to be work, or at least - playback is working, in my browsers and media players. However, if I try to run pavucontrol to make some settings - which usually works - it tells me:

    Connection to pulseaudio failed

    in this case etc. etc. This situation can also arise if pulseaudio crashed etc. etc. If this is the case, then PulseAudio should autospawn again, or if this is not configured you should run start-pulseaudio-x11 manually.

    So, I don't know if autospawn is configured, but in /etc/pulse/client.conf it says:

    ; autospawn = yes
    

    and daemon.conf it doesn't mention autospawning. Anyway, there is no process with pulse in its name, nor a kernel module.

    Here are the kernel modules with snd in their name:

    nd_hda_codec_hdmi     49152  2
    snd_hda_codec_realtek    90112  1
    snd_hda_codec_generic    69632  1 snd_hda_codec_realtek
    snd_usb_audio         180224  0
    snd_usbmidi_lib        28672  1 snd_usb_audio
    snd_hda_intel          36864  1
    snd_rawmidi            32768  1 snd_usbmidi_lib
    snd_seq_device         16384  1 snd_rawmidi
    snd_hda_codec         135168  4 snd_hda_intel,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_codec_realtek
    snd_hda_core           86016  5 snd_hda_intel,snd_hda_codec,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_codec_realtek
    snd_hwdep              16384  2 snd_hda_codec,snd_usb_audio
    snd_pcm               110592  5 snd_hda_intel,snd_hda_codec,snd_usb_audio,snd_hda_core,snd_hda_codec_hdmi
    snd_timer              32768  1 snd_pcm
    snd                    86016  14 snd_hda_intel,snd_hwdep,snd_hda_codec,snd_usb_audio,snd_timer,snd_rawmidi,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_usbmidi_lib,snd_seq_device,snd_hda_codec_realtek,snd_pcm
    soundcore              16384  1 snd
    usbcore               253952  8 uvcvideo,usbhid,snd_usb_audio,usb_storage,xhci_pci,snd_usbmidi_lib,uas,xhci_hcd
    

    So, I tried restarting the service, and here's what I got:

    $ start-pulseaudio-x11 
    Connection failure: Connection refused
    pa_context_connect() failed: Connection refused
    

    and if I try that as root, I get:

    # start-pulseaudio-x11
    XDG_RUNTIME_DIR (/run/user/1000) 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.)
    Connection failure: Connection refused
    pa_context_connect() failed: Connection refused
    

    Another thing I tried:

    $ pulseaudio --start --verbose
    E: [pulseaudio] main.c: Daemon startup failed.
    

    But there is something interesting going on: /var/log/syslog is being filled with more and more of the following:

    Jan 28 22:01:16 myhostname pulseaudio[22085]: [pulseaudio] cli-command.c: stat('/usr/share/pulseaudio/default.pa'): No such file or directory
    Jan 28 22:01:16 myhostname pulseaudio[22085]: [pulseaudio] main.c: Failed to initialize daemon.
    Jan 28 22:01:16 myhostname pulseaudio[22082]: [pulseaudio] main.c: Daemon startup failed.
    

    so, there's a continuing failing attempt at a respawn, and it's missing a file.

    What should I do?

    • kostix
      kostix over 5 years
      Does pactl info also fail?
    • kostix
      kostix over 5 years
      JFTR your audio might work using direct acces to ALSA (which is a lower-level sound manupulation layer). For instance, chromium in Debian was (is?) by default configured to use ALSA directly. I mean, there might be no correlation between "sound works" and "PulseAudio is used"—quite possibly you did not have any pulseaudio daemon running. Still, in "normal" Debian, running it is just a matter of executing pulseaudio --start as a regular user.
  • kostix
    kostix over 5 years
    So, you've got the problem sorted, right? If yes, that's good, but now please accept your own answer (that's perfectly OK on StackExchange network).
  • einpoklum
    einpoklum over 5 years
    @kostix: I know, but it takes a full day or two before I can accept my own answer - it's a SX restriction. Thanks for your help.
  • einpoklum
    einpoklum almost 5 years
    I'm no longer working on that system so I can't evaluate your suggestion...
  • Jaap Joris Vens
    Jaap Joris Vens over 3 years
    You really shouldn't have to do this by hand. If this worked for you, something went wrong way before this point.