Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@mklaber

This comment has been minimized.

Copy link

commented Aug 31, 2015

Works like a charm, thanks!

@brego

This comment has been minimized.

Copy link

commented Sep 8, 2015

👍 Thanks!

@a-r-m-a-n

This comment has been minimized.

Copy link

commented Oct 31, 2015

Thanks! =)

@yatrikp

This comment has been minimized.

Copy link

commented Nov 24, 2015

Thanks.. it works!!!

@ShamilyJegadeesh

This comment has been minimized.

Copy link

commented Jan 8, 2016

Thanks.. It works 👍

@cladera

This comment has been minimized.

Copy link

commented Jan 27, 2016

Thanks!!!!

@njt1982

This comment has been minimized.

Copy link

commented Jan 28, 2016

Does not work on El Capitain... First command crashed OS X and caused a reboot.

@zakiaziz

This comment has been minimized.

Copy link

commented Jan 29, 2016

My El Capitain didn't crash or reboot but still did not work.
First command yielded:

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

and second command just turned off my bluetooth without the ability to turn it back on

@ramv-dailymotion

This comment has been minimized.

Copy link

commented Feb 16, 2016

👍

@aks0

This comment has been minimized.

Copy link

commented Feb 19, 2016

@zakiaziz: were you able to figure this out? I'm facing the same issue.

@MauroNigrele

This comment has been minimized.

Copy link

commented Mar 5, 2016

Thanks! works fine on Yosemite

@gaizka-allende

This comment has been minimized.

Copy link

commented Mar 7, 2016

Thanks!

@mnnit-geek

This comment has been minimized.

Copy link

commented Mar 16, 2016

Not working in El Captain
❯❯❯ sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport ⏎ ⬆ ◼ (git:ir_646)
Password:
(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel) Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

@justinmpier

This comment has been minimized.

Copy link

commented Apr 6, 2016

Thanks!

@BerkeleyTrue

This comment has been minimized.

Copy link

commented Apr 9, 2016

Works great!

@jruzafa

This comment has been minimized.

Copy link

commented Apr 19, 2016

works fine with 10.10.5 Yosemite

@promiseofcake

This comment has been minimized.

Copy link

commented Apr 26, 2016

Thanks!

@coke

This comment has been minimized.

Copy link

commented May 3, 2016

WOOT. Thank you.

@kaosbeat

This comment has been minimized.

Copy link

commented May 19, 2016

perfect! (10.10.5)

@Dilts

This comment has been minimized.

Copy link

commented May 27, 2016

worked perfectly (10.10.5)

@ghost

This comment has been minimized.

Copy link

commented Jul 7, 2016

worked perfectly (10.10.5)

@perlun

This comment has been minimized.

Copy link

commented Jul 11, 2016

As others have said, fails completely on 10.11.5 (El Capitan).

@ralph-hm

This comment has been minimized.

Copy link

commented Jul 16, 2016

I couldn't find a similar solution on 10.11 (El Capitan), so i decided to restart the whole Bluetooth Module. Should work in upcoming versions too. See this gist: https://gist.github.com/ralph-hm/a65840c4f5e439b90170d735a89a863f

@maor

This comment has been minimized.

Copy link

commented Jul 21, 2016

As others have said, fails completely on 10.11.5 (El Capitan).

Beware: Failed for me too on El Capitan.

@victorhguillen

This comment has been minimized.

Copy link

commented Aug 16, 2016

A GUI version:

@AnsonFreeman

This comment has been minimized.

Copy link

commented Aug 24, 2016

Do not work on El Capitan

@todd-alexion

This comment has been minimized.

Copy link

commented Aug 30, 2016

Worked for me on Yosemite (10.10.5). Thanks.

@vj12354

This comment has been minimized.

Copy link

commented Sep 8, 2016

Awesome..! Worked like a charm..! Thanks.

@AliakseiMat

This comment has been minimized.

Copy link

commented Nov 4, 2016

Awesome!

@franciscbalint

This comment has been minimized.

Copy link

commented Nov 8, 2016

Thank you @nicolasembleton!
I added turn on/off option to this script if someone also needs it.
https://gist.github.com/0xfib/d008370c49a37f7051b1afef8567fefd

@mlindhout

This comment has been minimized.

Copy link

commented Nov 18, 2016

Nice!

@jabrena

This comment has been minimized.

Copy link

commented Nov 23, 2016

It works!!!

@j0hnsmith

This comment has been minimized.

Copy link

commented Nov 29, 2016

I've got a jagged line through the bluetooth icon in the menu bar, this doesn't work for me unfortunately.

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).
@davwilliams

This comment has been minimized.

Copy link

commented Dec 29, 2016

Just what I needed. And it works, too. :-) Thanks!

@maurotdo

This comment has been minimized.

Copy link

commented Jan 30, 2017

Flawless, just what i needed after bluetooth stopped working after a wake up from sleep

@Frozik

This comment has been minimized.

Copy link

commented Mar 3, 2017

Works for me, thanks!

@Henryvart

This comment has been minimized.

Copy link

commented Mar 11, 2017

Worked for me! Yosemite 10.10.5. Thank you!

@kierenjohnson

This comment has been minimized.

Copy link

commented Mar 28, 2017

Worked on MacOS Sierra 10.12.3. Thanks!

@barnesry

This comment has been minimized.

Copy link

commented Apr 5, 2017

Just saved me rebooting even after shift-option click to restart the BT module via debug menu didn't work. Thanks!

@Alfahad

This comment has been minimized.

Copy link

commented Apr 5, 2017

Thanks!

@kayakinwunmi

This comment has been minimized.

Copy link

commented Apr 23, 2017

Thank you!

@netojose

This comment has been minimized.

Copy link

commented May 21, 2017

Works on Sierra.
Thanks, sometimes the bluetooth crashes

@renatop7

This comment has been minimized.

Copy link

commented May 21, 2017

Worked perfectly for me, thanks!!
I'm using Yosemite 10.10.5

@Snehasispanigrahi

This comment has been minimized.

Copy link

commented Jun 16, 2017

Doesn't work on El Captain! Restart needed.

@patricknieto

This comment has been minimized.

Copy link

commented Jun 22, 2017

El Capitan 10.11.6:
(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances: (kernel) Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance. Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

@blattmann

This comment has been minimized.

Copy link

commented Jun 29, 2017

Thanks! Worked perfectly on Yosemite 10.10.5

@lamlai

This comment has been minimized.

Copy link

commented Jul 1, 2017

Thank so much!

@DTownSMR

This comment has been minimized.

Copy link

commented Aug 23, 2017

Thanks much!

Working for me on Sierra 10.12.6.

Plus fixes my magic mouse connection issue instantly. :-)

@designbyadrian

This comment has been minimized.

Copy link

commented Sep 28, 2017

High Sierra:

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).
@SMINT

This comment has been minimized.

Copy link

commented Oct 10, 2017

Need solution for high sierra, after sleep Bluetooth dead until restart

@harveyphan

This comment has been minimized.

Copy link

commented Nov 6, 2017

High sierra, pain in the ass. Anyone know this trick for this OS?

@laopunk

This comment has been minimized.

Copy link

commented Nov 16, 2017

you saved me a reboot, thanks a lot !

@henning

This comment has been minimized.

Copy link

commented Nov 19, 2017

First command:

$ sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
Password:
(kernel) Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport not found for unload request.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) not found.

on Sierra, 10.12.6, MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)

I don't get why this seems to work only for ~50% of people as I see about the same amount of "thanks" as "doesn't work for me" messages here... anyone got an idea?

@henning

This comment has been minimized.

Copy link

commented Nov 19, 2017

Answering myself:

kextfind -loaded | grep -i blue

reveals that on my MacBook there are different dirvers loaded.

Unloading them "works", but I have to explicitly unload IOBluetoothHostControllerUARTTransport and IOBluetoothHostControllerTransport

like

sudo kextunload -b com.apple.iokit.IOBluetoothHostControllerUARTTransport
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

Bluetooth devices /keyboard, trouchpad)stop working as expected.
On loading them again (replacing unload with load in the previous command), screen blacks out and system seems to do a warm restart.
Bluetooth works after that again for keyboard and external touchpad, but the bleutooth speaker, for which I tried toi do this all, still doesn't work, even though it always used to work for months now, and just this morning stopped being available as audio device, while being shown as connected as bluetooth device.

@PabloGBarcelo

This comment has been minimized.

Copy link

commented Nov 21, 2017

Great! it works like a charm!

@gbmeuk

This comment has been minimized.

Copy link

commented Nov 22, 2017

@henning, I agree. This used to work without fail but seems to be intermittent now; and comes with the error you're seeing. Haven't done much testing but hopefully people will SEE THIS MESSAGE and post what OS version their running, along with the device (from the  menu > about this mac)

System Version: macOS 10.13.1
Model Name: MacBook Pro
Model Identifier: MacBookPro10,1

@AndrewJHart

This comment has been minimized.

Copy link

commented Nov 28, 2017

this is fantastic! Thanks so much 👍

@jhash

This comment has been minimized.

Copy link

commented Dec 12, 2017

I love you!

@Xyverz

This comment has been minimized.

Copy link

commented Jan 5, 2018

I was having an issue and getting the "failed to unload" error as well. I had my trackpad plugged in via USB though. As soon as I unplugged the trackpad and ran the command again, I got the same error, but the bluetooth services reset themselves and my trackpad connected via Bluetooth again.

@McChubby

This comment has been minimized.

Copy link

commented Feb 2, 2018

@gbmeuk & @henning,
my details:
System version: 10.13.2
Model Name: MacBook Pro
Model Identifier: MacBookPro10,1

Issue: Currently experiencing trouble with reconnecting my bluetooth headset and even the bluetooth process on my Mbp looks like it is not finding any other bluetooth devices (tried other devices like my smartphone etc). In most situations (putting my mbp to sleep) the issue of reconnecting my headset starts. Now normally a reboot of my OS is sufficient too re-align the processes in the correct order. But even that won't do the trick atm. I found this script and the alternate version that @0xfib shared. both version don't seem to be working, getting the same return values as reported by other users. Are you guys currently anyway closer to a solution?

Returned values:

./bluetooth_restart.sh
(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 2 instances.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).
Bluetooth restarted
@imsrc21

This comment has been minimized.

Copy link

commented Mar 5, 2018

Getting error on macOS 10.13.3

./restart_bluetooth.sh 1

(kernel) Can't remove kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; services failed to terminate - 0xdc008018.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).
Bluetooth is on
@uyjulian

This comment has been minimized.

Copy link

commented Apr 7, 2018

macOS 10.13.4 works fine here to fix my bluetooth speaker connection

$ sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 5 instances.
$ sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

The more you do this, the more the number counts up

$ sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 6 instances.
$ sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

Let's get to 2,147,483,647?

This might also help:

sudo launchctl stop com.apple.bluetoothd;sudo launchctl stop com.apple.diagnosticextensions.osx.bluetooth.helper;sudo launchctl stop com.apple.bluetoothReporter;sudo launchctl stop com.apple.IOBluetoothUSBDFU; sudo launchctl stop com.apple.bluetoothaudiod;sudo kextunload -v 6 -b com.apple.iokit.IOBluetoothFamily;sudo kextunload -v 6 -b com.apple.iokit.IOBluetoothHostControllerTransport;sudo kextunload -v 6 -b com.apple.iokit.IOBluetoothHostControllerUSBTransport;sudo kextunload -v 6 -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@uyjulian

This comment has been minimized.

Copy link

commented Apr 18, 2018

I found a even better solution.
Turn Bluetooth+Wifi off, then turn Wifi+Bluetooth on.
Works perfectly for me every time :-)

@ajain-bst

This comment has been minimized.

Copy link

commented May 8, 2018

@uyjulian Thank you! It works!

@kriskhaira

This comment has been minimized.

Copy link

commented Jun 10, 2018

@uyjulian's solution worked for me on High Sierra 10.13.5. Thank you!

@10fish

This comment has been minimized.

Copy link

commented Jun 22, 2018

codes above gives following response:

(kernel) Can't remove kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; services failed to terminate - 0xxxxxx.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

but this blueutil works for me on 10.13.5.

@max-lobur

This comment has been minimized.

Copy link

commented Jul 2, 2018

High Sierra 10.13.5 (MBP 13 Early 2015)
https://github.com/max-lobur/dotfiles/blob/master/sh/bt.sh - managed to fix like this

@will-dee

This comment has been minimized.

Copy link

commented Jul 3, 2018

One solution which works for me on High Sierra is to kill the bluetooth daemon. It auto restarts which seems to sort it out. Here's a one liner (note it has to be done under sudo because the bluetoothd process isn't owned by $USER):

sudo kill -9 `pgrep bluetoothd`
@charafsalmi

This comment has been minimized.

Copy link

commented Jul 19, 2018

➜ ~ ./restart_bluetooth.sh
(kernel) Can't remove kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; services failed to terminate - 0xdc008018.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

➜ ~ uname -a
Darwin MacBook-Pro-XXX.local 18.0.0 Darwin Kernel Version 18.0.0: Sun Jun 10 19:23:56 PDT 2018; root:xnu-4903.200.249~5/RELEASE_X86_64 x86_64
➜ ~ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 10.14 (18A314k)
Kernel Version: Darwin 18.0.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: XXX
User Name: XXX
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 5 days 1:43

@thehalvo

This comment has been minimized.

Copy link

commented Jul 26, 2018

Thanks!

@Jiff21

This comment has been minimized.

Copy link

commented Aug 3, 2018

I'm on sierra and was getting the same 'Can't remove ...' error. You can just hold Shift+Option and click on the Bluetooth Icon Top Menu, It will reveal an option called Debug Menu item that has a Reset the Bluetooth Module option.

If you need to do this in terminal for some reason, stackoverflow suggests.

sudo launchctl stop com.apple.blued
sudo launchctl start com.apple.blued
@solderjs

This comment has been minimized.

Copy link

commented Aug 18, 2018

A Comprehensive Solution

/usr/local/bin/blueutil -p 0 alone didn't work for me, I did this:

~/.local/bin/restart-bluetooth:

#!/bin/bash

# Docs I read
# https://gist.github.com/nicolasembleton/afc19940da26716f8e90
# https://gist.github.com/ralph-hm/a65840c4f5e439b90170d735a89a863f
# https://github.com/max-lobur/dotfiles/blob/master/sh/bt.sh

# Things I had to do beforehand
#brew install blueutil
# Restart bluetooth every time good ol' lappy wakes up:
#brew install sleepwatcher
#sudo mkdir -p /usr/local/sbin
#sudo chown -R $(whoami):staff /usr/local/sbin/
#brew link sleepwatcher
#/usr/local/sbin/sleepwatcher --verbose -w ~/.local/bin/restart-bluetooth
#brew services start sleepwatcher


# Stop all the bluetooth stuff
sudo kill -9 $(pgrep bluetoothd)
/usr/local/bin/blueutil -p 0
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextunload -b com.apple.iokit.IOBluetoothHostControllerUARTTransport
sudo launchctl stop com.apple.blued

# Start enough of the bluetooth stuff
/usr/local/bin/blueutil -p 1
sudo launchctl start com.apple.blued
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

It's only sometimes that my bluetooth doesn't reconnect after sleep & wake (may be related to docking to my Thunderbolt Display) and I don't know how to immediately cause the problem, so I don't know what about that process is required. Obviously some of it is superfluous, but if I run that script my bluetooth dies and comes right back, so I know it's working well enough.

If someone can pare it down to just what's necessary I'd love to hear the explanation (ping me @coolaj86).

@BryanBo-Cao

This comment has been minimized.

Copy link

commented Oct 1, 2018

Awesome!!! Thanks!!!

@HouCoder

This comment has been minimized.

Copy link

commented Nov 29, 2018

@will-dee thanks, your solution worked for my Hackintosh!!

@daremosan

This comment has been minimized.

Copy link

commented Dec 24, 2018

I've got a jagged line through the bluetooth icon in the menu bar, this doesn't work for me unfortunately.

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

Same

@ahadrez

This comment has been minimized.

Copy link

commented Jan 2, 2019

+1

@thefonso

This comment has been minimized.

Copy link

commented Jan 7, 2019

Ahhhh still works like a charm Mac OS Sierra

@psabbate

This comment has been minimized.

Copy link

commented Jan 11, 2019

Thanks @coolaj86

@mirko77

This comment has been minimized.

Copy link

commented Feb 5, 2019

I've got a jagged line through the bluetooth icon in the menu bar, this doesn't work for me unfortunately.

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

Same

Same +1

@nageshever

This comment has been minimized.

Copy link

commented Feb 9, 2019

worked for me

@mgguinne

This comment has been minimized.

Copy link

commented Feb 10, 2019

I've got a jagged line through the bluetooth icon in the menu bar, this doesn't work for me unfortunately.

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

Same

Same +1

Same +1
Have 2 x 15" macbook pros 2012/2013 and since being on 10.14 does it quite often after waking from sleep. Reboot only way to fix :(

@teseo

This comment has been minimized.

Copy link

commented Feb 24, 2019

I've got a jagged line through the bluetooth icon in the menu bar, this doesn't work for me unfortunately.

(kernel) Can't unload kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport; classes have instances:
(kernel)     Kext com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport class BroadcomBluetoothHostControllerUSBTransport has 1 instance.
Failed to unload com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport - (libkern/kext) kext is in use or retained (cannot unload).

Same

Same +1

Same +1

@lorenz068

This comment has been minimized.

Copy link

commented Mar 12, 2019

@uyjulian restart wifi & bluetooth works Thank you!

@Yogibeer2001

This comment has been minimized.

Copy link

commented Mar 24, 2019

@uyjulian solution worked on Sierra 10.12.6
it appears to have conflict with Wifi. will investigate further

@stefandeml

This comment has been minimized.

Copy link

commented Apr 2, 2019

anybody aware of a solution that works for Mojave 10.14.1?

@MatiMenich

This comment has been minimized.

Copy link

commented Apr 2, 2019

@stefandemi +1

@elifiner

This comment has been minimized.

Copy link

commented Apr 6, 2019

I kept coming back to this and finally stumbled on this answer on stackoverflow:
https://stackoverflow.com/questions/17345305/unload-kext-which-still-has-instances

Using the method there I saw that com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport is referenced by com.apple.iokit.BroadcomBluetooth20703USBTransport and that is why it can't be unloaded. Looks like unloading them in dependency order and loading them in reverse order works correctly.

This is the script I'm now using that seems to work for me:

#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetooth20703USBTransport
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetooth20703USBTransport

There's also a fuller version that reconnects any previously connected devices using blueutil:

#!/bin/bash
devices=$(blueutil --paired | grep -v "not connected" | awk -F '[ ,]' '{print $2}')
sudo kextunload -b com.apple.iokit.BroadcomBluetooth20703USBTransport
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetooth20703USBTransport
for device in $devices; do
    for retry in {1..5}; do
        if blueutil --connect $device 2> /dev/null; then break; fi
        sleep 1
    done
done
@daveokeeffe

This comment has been minimized.

Copy link

commented Apr 24, 2019

None of these things worked for me - I was forced to reboot my mac in order to get bluetooth working properly again.

I'm on a MacBook Pro (15-inch, 2018) running Mojave 10.14.4

@daveokeeffe

This comment has been minimized.

Copy link

commented Apr 24, 2019

None of these things worked for me - I was forced to reboot my mac in order to get bluetooth working properly again.

I'm on a MacBook Pro (15-inch, 2018) running Mojave 10.14.4

@daveokeeffe

This comment has been minimized.

Copy link

commented Apr 24, 2019

None of these things worked for me - I was forced to reboot my mac in order to get bluetooth working properly again.

I'm on a MacBook Pro (15-inch, 2018) running Mojave 10.14.4

@steakknife

This comment has been minimized.

Copy link

commented Apr 30, 2019

@mgguinne Looks like Apple is breaking "vintage" Macs to sell more new ones. No sale.

@al3x-huang

This comment has been minimized.

Copy link

commented May 5, 2019

None of these things worked for me either, I'm on a 2015 Macbook pro 13'' with Retina Display and have had this problem since 2015. Currrently on 10.13.5...

@timothymarois

This comment has been minimized.

Copy link

commented May 10, 2019

None of these work here. Latest MacOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.