My bluetooth headset works fine. Audio sink works. Everything work. But the problem is that I need to connect it manually to the PC:

  • click on bluetooth icon near the time on kde taskbar => known devices => Connect
  • # bluetoothctl => connect xx:xx:xx:xx:xx:xx

It used to connect automatically just a month ago with standard debian installation/updates. I don't know why it got broken. I didn't install any bluetooth-related packages nor change bluetooth-related configuration files.

What I did to fix my problem:

  • purged and reinstalled all bluetooth-related packages (see below).
  • added a line load-module module-switch-on-connect to /etc/pulse/default.pa as described here
  • created a file /etc/bluetooth/audio.conf with a line AutoConnect=true and restarted bluetooth service afterwards, as said here
  • script (from askubuntu) does not work. I get this message:

    Browsing 00:18:09:29:XX:XX ...
    Sink bluez_sink.00_18_09_29_XX_XX does not exist.

How to make it to be able to connect to bluetooth headset automatically when it goes online? I feel like the solution is easy.

Debian 8.6, kde 4.14.2. Packages used: bluedevil, bluetooth, bluez, pulseaudio-module-bluetooth.


6 Answers 6


Normally your headset should try to connect to last device it connected automatically (most, if not all, does that). However this may fail if your device is not a trusted device.

First thing to check is the log files. In Ubuntu under /var/log/syslog, may have different name under Debian... There I saw the error: Authentication attempt without agent

A quick web search returned this page and all I needed to do is to add device to trusted devices. Run bluetoothctl and then enter trust XX:XX:XX:XX:XX:XX. Replace X'es with MAC address of your device. There is example in the link I provided also

You may have a different problem, but check your log files at least to see if your device is trying to connect. If it is trying to connect, you can also see some messages if you run bluetoothctl and wait. I kept seeing Connected: yes , no , yes , no... messages all the time. It was being disconnected because it was not a trusted device.

  • 12
    I did trust, and check if it trusted. It was trusted and still I have to disconnect and connect again to be able to use headset. Sometimes I have to repeat the operation (disconnect->connect)
    – Qeeet
    Commented Jun 19, 2017 at 22:09
  • 1
    my trusted device keeps connecting and disconnecting. Here is the log [NEW] Controller YYY [default] [NEW] Device XXXXXX Bluedio T Agent registered [Bluedio T]# trust XXXXXX Changing XXXXXX trust succeeded [CHG] Device XXXXXX ServicesResolved: no [CHG] Device XXXXXX Connected: no [CHG] Device 18:01:15:8B:0C:31 Connected: yes [CHG] Device XXXXXX Connected: no [bluetooth]# trust XXXXXX Changing XXXXXX trust succeeded [bluetooth]# connect XXXXXX Attempting to connect to XXXXXX [CHG] Device XXXXXX Connected: yes Connection successful [CHG] Device XXXXXX ServicesResolved: yes Commented May 28, 2019 at 7:22

Auto-reconnection also did not work for me on ubuntu 19 using a creative bt speaker.

I used the answer and comment above to combine trusting and disconnect, connect with a short shell script. I made a desktop link to execute the script conveniantly.

You can find the correct MAC address in the bluetooth settings of ubuntu.

Script: (save it as /home/username/connect_speaker.sh)

bluetoothctl trust MAC-address
bluetoothctl disconnect MAC-address
bluetoothctl connect MAC-address

speaker.desktop (link)

#!/usr/bin/env xdg-open
[Desktop Entry]
Comment[en_US]=connect bt speaker
Comment=connect bt speaker

A desktop link is also just a file. replace the username with your username on the system. I saved a speaker icon in /usr/share/icons/hicolor/256x256/apps as speaker.png Ubuntu will automatically find it.

  • 12
    Astonishing the still in 2020 cutting edge Ubuntu/debian testing still can't do bluetooth properly out of the box. No reconnect after waking from suspend.
    – RichieHH
    Commented Feb 26, 2020 at 7:22
  • 1
    change script: #!/usr/bin/bash bluetoothctl trust 4E:16:45:65:8F:44 echo -e 'connect 4E:16:45:65:8F:44' | bluetoothctl if icon doesnt match, type full path Commented Nov 25, 2020 at 7:57

Besides adding trust you also need to make pulseaudio accept the connection. Citing from https://wiki.archlinux.org/index.php/Bluetooth_Headset#Setting_up_auto_connection ...

To make your headset auto connect you need to enable PulseAudio's switch-on-connect module. Do this by adding the following lines to /etc/pulse/default.pa:

# automatically switch to newly-connected devices
load-module module-switch-on-connect

Now make bluetoothctl trust your Bluetooth headset by running trust 00:1D:43:6D:03:26 inside the bluetoothctl console


I wrote a simple script that will keep reconnecting the device when you reboot your PC or when the device toggles bluetooth status or lose a signal for a while.



powered() {
    echo "show" | bluetoothctl | grep "Powered" | cut -d " " -f 2

connected() {
    echo "info ${MAC}" | bluetoothctl | grep "Connected" | cut -d " " -f 2

while true
    sleep 1
    if [ $(powered) = yes ] && [ $(connected) = no ]; then
        echo "connect ${MAC}" | bluetoothctl
        sleep 5
  1. Update MAC variable with your device's MAC address. (speaker, smartphone...)
    echo "devices" | bluetoothctl | grep Device
  2. Save the script for example as a ~/.bt-autoconnect.sh
  3. Make it executable chmod +x ~/.bt-autoconnect.sh
  4. Run it at login echo "~/.bt-autoconnect.sh &" >> "~/.xprofile"

In my case this Script works (I tried all setting but not work for me,Step 5 from Here)

Python script on GitHub called bluetooth-autoconnect. It’s a python script that automatically connects to all paired and trusted Bluetooth devices. However, the script is not available to install directly on Flatpak or Apt repository. Hence, we need to manually download and configure the service.

download the zip file from GitHub or use the following command to clone the repository to your home directory.

git clone https://github.com/jrouleau/bluetooth-autoconnect.git

Now that we have the repository downloaded we need to move the service and scripts to their respective location before we start the service. In systemd architecture:-

sudo cp bluetooth-autoconnect/bluetooth-autoconnect.service /etc/systemd/system/

sudo cp bluetooth-autoconnect/bluetooth-autoconnect /usr/bin/

Once, we have successfully copied the service to the respective directories, let’s enable and start the service. To do that, use the following command.

sudo systemctl enable bluetooth-autoconnect.service 
sudo systemctl start bluetooth-autoconnect.service

Now remove and again connect and Done.

The only caveat with this method is that you won’t be able to pair your Bluetooth device with other systems without switching off your Linux machine’s Bluetooth.


this is already incorporated into the /etc/pulse/default.pa in Ubuntu 20.04

.ifexists module-switch-on-connect.so
load-module module-switch-on-connect

You must log in to answer this question.

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