67

I was able to listen with my BT headset, but suddenly, one day, it disappeared from sound settings forever!

I've even re-paired my headset (and its connected already) but it doesn't have any options in sound settings in order to listen from it.

When I try this command:

hcitool scan

It doesn't find any devices! Even this command:

pactl list cards short

Only lists my default sound card only! What should I do?

Tim
  • 32,861
  • 27
  • 118
  • 178
  • Not an answer to this question, but I found this question when searching for my problem and maybe my comment helps others aswell; I saw my bluetooth sink in pactl list short sinks and was unable to play music with it. Disconnecting via bluetoothctl and requesting the default agent (thus typing bluetoothctl, then disconnect, then default-agent, and then connect [device]) helped me. – mutableVoid Oct 04 '23 at 09:37
  • I had this issue just now with a fresh Ubuntu 22.04 and new Sony buds, and the solution for me was... try repairing a third time. Didn't show up in sound settings the first two times, but did on the third. No idea why. – joe Feb 18 '24 at 05:14

7 Answers7

32

Extending upon Mark's answer, which basically did the trick for me.

The problem is that the bluetooth service tries to load the pulseaudio bluetooth module at startup, which fails because they require X11 to be running. You need to change the configuration so that the pulseaudio bluetooth module is loaded after X11.

  1. Tell the bluetooth service to not load the module. To do this, edit /etc/pulse/default.pa and comment out these lines by putting # characters in front of them:

    .ifexists module-bluetooth-discover.so
    load-module module-bluetooth-discover
    .endif
    
  2. Configure the module to be loaded after X11. To do this, edit /usr/bin/start-pulseaudio-x11 and add two lines:

    if [ x"$DISPLAY" != x ] ; then
        # ...
    
        # Add these lines:
        /usr/bin/pactl load-module module-bluetooth-discover
        /usr/bin/pactl load-module module-switch-on-connect
    fi
    
  3. Restart pulseaudio and bluetooh. Either reboot your machine or use the following commands:

    pulseaudio -k
    start-pulseaudio-x11
    sudo service bluetooth restart
    

This way, the pulseaudio bluetooth module should be working and Volume Control (pavucontrol) should detect the bluetooth device and list it under input and output devices.

danijar
  • 636
  • 1
  • 9
  • 15
  • 1
    The above doesn't work for me; instead, I get start-pulseaudio-x11 /usr/bin/start-pulseaudio-x11: 24: /usr/bin/start-pulseaudio-x11: /usr/bin/pact1: not found – DarrenRhodes Apr 18 '18 at 18:10
  • 2
    @user1945827 : it's "pactl", not "pact1". It stands for PulseAudio Control. – static_rtti May 02 '18 at 19:44
  • 1
    @static_rtti thanks. I managed to get it working. – DarrenRhodes May 03 '18 at 13:34
  • 5
    I'm voting up but all I needed was to sudo service bluetooth restart – wranvaud Mar 11 '19 at 23:40
  • Thanks, this worked for me after a full system reboot (restarting the service didn't work. I am on Arch linux and all was well until I did a full system update last week. The only thing that isn't working is the output selector in the top right of Gnome, it doesn't show multiple outputs, just one. So I have to open sound settings to choose it, but at least it is in the list now. – Elijah Lynn Jul 16 '20 at 16:47
  • This does not work in Ubuntu 20.04 – con Nov 01 '20 at 02:12
  • The three commands of step 3. saved me a reboot on Ubuntu 20.04. – Ben Mares Feb 08 '22 at 14:36
  • Thaaanks, works perfectly <3 – Anoesj Sadraee Jan 26 '23 at 08:13
30

Try this command:

sudo -H pactl load-module module-bluetooth-discover

I run this whenever I have paired, and successfully connected, but still can't see them in sound settings. It essentially tells pulseaudio to load reload it's list of bluetooth devices.

Tim
  • 32,861
  • 27
  • 118
  • 178
  • In what situations would you use this command? – belacqua Jun 11 '14 at 20:30
  • @belacqua Whenever I can't see my headset in the sound settings. – Tim Jun 11 '14 at 20:31
  • 4
    You might consider adding a little more context -- people just seeing this command probably have little idea what it does, whether it's sketchy, whether it needs to be repeated on reboots, etc.. – belacqua Jun 11 '14 at 20:34
  • 14
    Why was this answer accepted? What caused the problem to begin with, and what's the long-term fix? Ubuntu bluetooth worked perfectly for me, and then after a power outage it stopping working entirely. This command fixes it, but having to manually run this command every time I want to use bluetooth is not a solution. I've downvoted this answer until more explanation is provided. – Cerin Sep 05 '14 at 18:18
  • 2
    @Cerin, okay, what do you want to know? It works - you admited that - if it was helpful you should upvote. It was accepted because it solved the OP's problem. If it solves it it is a solution. – Tim Sep 05 '14 at 20:24
  • 3
    I'm having this same problem on Ubuntu 14.04. However, this solution did not work for me. – Ashwin Nanjappa Sep 13 '14 at 03:00
  • @Cerin ? You didn't explain it - any suggestions for how to improve the answer would be appreciated. – Tim Mar 16 '15 at 13:42
  • @Tim, It doesn't solve the problem because the problem comes back almost immediately. – Cerin Mar 16 '15 at 17:15
  • I would disagree. Solving is: "effectively dealing with a problem". While this is a temporary solution, it is one, and it does, if temporarily solve it. Why not add it to cron? – Tim Mar 16 '15 at 17:17
  • @Tim, You don't fix a flat tire by putting a piece of scotch tap over the hole... This issue recently re-emerged for me in 14.04, and even this no longer "fixes" it. If we knew the underlying problem, we could find a better solution. – Cerin May 02 '15 at 16:32
  • @Cerin If you can automatically reapply the scotch tape when it falls off what's the difference? – Tim May 02 '15 at 17:30
  • 2
    @Tim, For your car's sake, I really hope you're just trolling me. Regardless, this appears to be an unresolved bug in pulseaudio. – Cerin Jul 03 '15 at 02:17
  • @Cerin Are you using Blueman or the default Bluetooth Manager? – Jeremy31 Jul 16 '15 at 20:39
  • 33
    I am getting this error: "Failure: Module initialization failed". Can anybody help? – Jay Chakra May 07 '16 at 20:03
  • 1
    This didn't work for me. Syslog: [pulseaudio] module.c: Module "module-bluetooth-discover" should be loaded once at most. Refusing to load. – Daniel Revell Oct 28 '16 at 07:19
  • Not solving the problem for me. module-bluetooth-discover (as well as -policy and bluez5-discover) gets loaded automatically. Still no sinks in pavucontrol besides the built-in speakers, and "1 card(s) available." in pacmd/pactl list-cards. – ulidtko Dec 27 '16 at 22:38
  • 1
    seems like the permanent solution is given in the answer below. I upvoted it and down-voted this one. – Bhikkhu Subhuti Dec 28 '16 at 00:18
  • 3
    @BhikkhuSubhuti the last update to that repository was 90 weeks ago - nearly 2 years. That is not a solution for 16.04 - in fact it hasn't worked since 15.04. – Tim Dec 28 '16 at 00:35
  • sorry.. I will upvote again. – Bhikkhu Subhuti Dec 28 '16 at 15:44
  • 11
    I get the following error: No protocol specified xcb_connection_has_error() returned true Connection failure: Connection refused pa_context_connect() failed: Connection refused – Startec Apr 28 '18 at 07:27
  • @Startec I’m afraid I no longer even have an Ubuntu computer, never mind have this issue! – Tim Apr 28 '18 at 10:51
  • 8
    I'm getting "Connection failure: Connection refused pa_context_connect() failed: Connection refused " – Gal Bracha Dec 13 '21 at 13:18
  • 1
    For Ubuntu 22.04 with PipeWire check this: https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Troubleshooting#missing-bluetooth-profiles – msch Aug 17 '22 at 20:16
  • 1
    Connection failure: Connection refused pa_context_connect() failed: Connection refused – Max Oct 20 '23 at 07:45
  • @Max https://askubuntu.com/questions/70560/why-am-i-getting-this-connection-to-pulseaudio-failed-error – Tim Oct 20 '23 at 08:40
22

I had the same problem on Ubuntu 20.04 with my Pixus Bluetooth headphones. The ubuntu Bluetooth manager saw the headphones and correctly connected them, but ALSA didn't see them.

You can check the list of Bluetooth devices by command

bluetoothctl devices

and you can check what outputs ALSA has by command

pactl list sinks short

The solution that I found is to set option ControllerMode to bredr in file /etc/bluetooth/main.conf

# Restricts all controllers to the specified transport. Default value
# is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).
# Possible values: "dual", "bredr", "le"
#ControllerMode = dual
ControllerMode = bredr

When you changed the option restart Bluetooth service

sudo gedit /etc/bluetooth/main.conf
sudo systemctl restart bluetooth

Then connect headphones again and check that ALSA sees it. If so then it must be shown as the available output in ubuntu sound settings

pactl list sinks short
enter code here
Alexey Muravyov
  • 766
  • 1
  • 7
  • 8
14

The headset is properly paired and shows under Bluetooth Devices but it does not show as an available INPUT / OUTPUT source for audio. The problem is that the pulseaudio bluetooth module is loaded before X11, changing a couple of config files do the trick:

PulseAudio can not load bluetooth module 15.10/16.04

nano /etc/pulse/default.pa

Comment out the following lines:

#.ifexists module-bluetooth-discover.so
#load-module module-bluetooth-discover
#.endif

nano /usr/bin/start-pulseaudio-x11

Find the following lines and add after them:

if [ x”$SESSION_MANAGER” != x ] ; then
/usr/bin/pactl load-module module-x11-xsmp “display=$DISPLAY session_manager=$SESSION_MANAGER” > /dev/null
fi

Add the following lines:

/usr/bin/pactl load-module module-bluetooth-discover
/usr/bin/pactl load-module module-switch-on-connect

This way the Pulse audio’s Bluetooth modules will not be downloaded at boot time but after x11 is started.

Mark
  • 1,502
  • 4
    Is there some service that needs to be restarted for these changes to take effect? – Michael Scheper Nov 08 '17 at 05:01
  • You can trigger them on the command line as in the answer above .... my post is how to have it automate on startup. – Mark Mar 27 '19 at 23:49
  • I think you're saying that if you type the three /usr/bin/pactl commands at the command line, they'll take effect immediately. It also looks like the two to add to /usr/bin/start-pulseaudio-x11 should be inside the if statement. Can you confirm both of these observations? Thanks! – Michael Scheper Apr 12 '19 at 23:01
  • 1
    The lines are inserted after the shown if..fi but within the larger if [ x"$DISPLAY"...fi. Yes, you should be able to execute the commands directly in terminal. – Mark Apr 13 '19 at 10:39
8

I am not able to comment on the top response, but I thought I'd add that on my Ubuntu MATE 12.04 LTS Laptop, I had to do:

sudo apt-get install pulseaudio-module-bluetooth

only then did this work

sudo -i pactl load-module module-bluetooth-discover

Then I had to go into bluetooth manager app, pair the device, then set to 'Audio Sink' mode, then I could see the device within the Ubuntu Sound options and manipulate inputs/outputs!

adowdy
  • 239
6

The permanent solution would be to add the blueman PPA and update your package to the latest version which has the bug fixed: https://launchpad.net/~blueman/+archive/ubuntu/ppa

sudo add-apt-repository ppa:blueman/ppa
sudo apt-get update
sudo apt-get upgrade

That way, you should no longer have to run the

sudo -i pactl load-module module-bluetooth-discover

command every time but only once. Works for me on 14.04 LTS (Trusty)

Source

Tim
  • 32,861
  • 27
  • 118
  • 178
  • This does not apply for 16.04. The repository has no release candidate for it. – k0pernikus Jan 06 '17 at 14:57
  • @k0pernikus Seems like you can just sudo apt install blueman directly in 16.04: https://askubuntu.com/questions/764273/ubuntu-16-04-wont-output-sound-to-bluetooth-headphones – Andrew Mao Dec 11 '17 at 19:28
1

In Ubuntu 23.10 disabling wireplumper did it: $ systemctl --user disable --now wireplumber

dr0i
  • 249
  • 1
  • 7