Create a gist now

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.

Show comment
Hide comment
@mklaber

mklaber Aug 31, 2015

Works like a charm, thanks!

mklaber commented Aug 31, 2015

Works like a charm, thanks!

@brego

This comment has been minimized.

Show comment
Hide comment
@brego

brego Sep 8, 2015

👍 Thanks!

brego commented Sep 8, 2015

👍 Thanks!

@a-r-m-a-n

This comment has been minimized.

Show comment
Hide comment
@a-r-m-a-n

a-r-m-a-n Oct 31, 2015

Thanks! =)

Thanks! =)

@yatrikp

This comment has been minimized.

Show comment
Hide comment
@yatrikp

yatrikp Nov 24, 2015

Thanks.. it works!!!

yatrikp commented Nov 24, 2015

Thanks.. it works!!!

@ShamilyJegadeesh

This comment has been minimized.

Show comment
Hide comment
@ShamilyJegadeesh

ShamilyJegadeesh Jan 8, 2016

Thanks.. It works 👍

Thanks.. It works 👍

@cladera

This comment has been minimized.

Show comment
Hide comment
@cladera

cladera Jan 27, 2016

Thanks!!!!

cladera commented Jan 27, 2016

Thanks!!!!

@njt1982

This comment has been minimized.

Show comment
Hide comment
@njt1982

njt1982 Jan 28, 2016

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

njt1982 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.

Show comment
Hide comment
@zakiaziz

zakiaziz 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

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.

Show comment
Hide comment

👍

@aks0

This comment has been minimized.

Show comment
Hide comment
@aks0

aks0 Feb 19, 2016

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

aks0 commented Feb 19, 2016

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

@MauroNigrele

This comment has been minimized.

Show comment
Hide comment
@MauroNigrele

MauroNigrele Mar 5, 2016

Thanks! works fine on Yosemite

Thanks! works fine on Yosemite

@gaizka-allende

This comment has been minimized.

Show comment
Hide comment

Thanks!

@mnnit-geek

This comment has been minimized.

Show comment
Hide comment
@mnnit-geek

mnnit-geek 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).

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.

Show comment
Hide comment

Thanks!

@BerkeleyTrue

This comment has been minimized.

Show comment
Hide comment
@BerkeleyTrue

BerkeleyTrue Apr 9, 2016

Works great!

Works great!

@jruzafa

This comment has been minimized.

Show comment
Hide comment
@jruzafa

jruzafa Apr 19, 2016

works fine with 10.10.5 Yosemite

jruzafa commented Apr 19, 2016

works fine with 10.10.5 Yosemite

@promiseofcake

This comment has been minimized.

Show comment
Hide comment

Thanks!

@coke

This comment has been minimized.

Show comment
Hide comment
@coke

coke May 3, 2016

WOOT. Thank you.

coke commented May 3, 2016

WOOT. Thank you.

@kaosbeat

This comment has been minimized.

Show comment
Hide comment
@kaosbeat

kaosbeat May 19, 2016

perfect! (10.10.5)

perfect! (10.10.5)

@Dilts

This comment has been minimized.

Show comment
Hide comment
@Dilts

Dilts May 27, 2016

worked perfectly (10.10.5)

Dilts commented May 27, 2016

worked perfectly (10.10.5)

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jul 7, 2016

worked perfectly (10.10.5)

ghost commented Jul 7, 2016

worked perfectly (10.10.5)

@perlun

This comment has been minimized.

Show comment
Hide comment
@perlun

perlun Jul 11, 2016

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

perlun commented Jul 11, 2016

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

@ralph-hm

This comment has been minimized.

Show comment
Hide comment
@ralph-hm

ralph-hm 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

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.

Show comment
Hide comment
@maor

maor Jul 21, 2016

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

Beware: Failed for me too on El Capitan.

maor 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.

Show comment
Hide comment
@victorhguillen

victorhguillen Aug 16, 2016

A GUI version:

A GUI version:

@AnsonFreeman

This comment has been minimized.

Show comment
Hide comment
@AnsonFreeman

AnsonFreeman Aug 24, 2016

Do not work on El Capitan

Do not work on El Capitan

@todd-alexion

This comment has been minimized.

Show comment
Hide comment
@todd-alexion

todd-alexion Aug 30, 2016

Worked for me on Yosemite (10.10.5). Thanks.

Worked for me on Yosemite (10.10.5). Thanks.

@vj12354

This comment has been minimized.

Show comment
Hide comment
@vj12354

vj12354 Sep 8, 2016

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

vj12354 commented Sep 8, 2016

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

@AliakseiMat

This comment has been minimized.

Show comment
Hide comment

Awesome!

@0xfib

This comment has been minimized.

Show comment
Hide comment
@0xfib

0xfib 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

0xfib 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.

Show comment
Hide comment

Nice!

@jabrena

This comment has been minimized.

Show comment
Hide comment
@jabrena

jabrena Nov 23, 2016

It works!!!

jabrena commented Nov 23, 2016

It works!!!

@j0hnsmith

This comment has been minimized.

Show comment
Hide comment
@j0hnsmith

j0hnsmith 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).

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.

Show comment
Hide comment
@davwilliams

davwilliams Dec 29, 2016

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

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

@maurotdo

This comment has been minimized.

Show comment
Hide comment
@maurotdo

maurotdo Jan 30, 2017

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

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

@Frozik

This comment has been minimized.

Show comment
Hide comment
@Frozik

Frozik Mar 3, 2017

Works for me, thanks!

Frozik commented Mar 3, 2017

Works for me, thanks!

@Henryvart

This comment has been minimized.

Show comment
Hide comment
@Henryvart

Henryvart Mar 11, 2017

Worked for me! Yosemite 10.10.5. Thank you!

Worked for me! Yosemite 10.10.5. Thank you!

@kierenjohnson

This comment has been minimized.

Show comment
Hide comment
@kierenjohnson

kierenjohnson Mar 28, 2017

Worked on MacOS Sierra 10.12.3. Thanks!

Worked on MacOS Sierra 10.12.3. Thanks!

@barnesry

This comment has been minimized.

Show comment
Hide comment
@barnesry

barnesry Apr 5, 2017

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

barnesry 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.

Show comment
Hide comment

Alfahad commented Apr 5, 2017

Thanks!

@kayakinwunmi

This comment has been minimized.

Show comment
Hide comment

Thank you!

@netojose

This comment has been minimized.

Show comment
Hide comment
@netojose

netojose May 21, 2017

Works on Sierra.
Thanks, sometimes the bluetooth crashes

netojose commented May 21, 2017

Works on Sierra.
Thanks, sometimes the bluetooth crashes

@renatop7

This comment has been minimized.

Show comment
Hide comment
@renatop7

renatop7 May 21, 2017

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

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

@Snehasispanigrahi

This comment has been minimized.

Show comment
Hide comment
@Snehasispanigrahi

Snehasispanigrahi Jun 16, 2017

Doesn't work on El Captain! Restart needed.

Doesn't work on El Captain! Restart needed.

@patricknieto

This comment has been minimized.

Show comment
Hide comment
@patricknieto

patricknieto 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).

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.

Show comment
Hide comment
@blattmann

blattmann Jun 29, 2017

Thanks! Worked perfectly on Yosemite 10.10.5

Thanks! Worked perfectly on Yosemite 10.10.5

@lamlai

This comment has been minimized.

Show comment
Hide comment
@lamlai

lamlai Jul 1, 2017

Thank so much!

lamlai commented Jul 1, 2017

Thank so much!

@DTownSMR

This comment has been minimized.

Show comment
Hide comment
@DTownSMR

DTownSMR Aug 23, 2017

Thanks much!

Working for me on Sierra 10.12.6.

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

Thanks much!

Working for me on Sierra 10.12.6.

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

@designbyadrian

This comment has been minimized.

Show comment
Hide comment
@designbyadrian

designbyadrian 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).

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.

Show comment
Hide comment
@SMINT

SMINT Oct 10, 2017

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

SMINT commented Oct 10, 2017

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

@harveyphan

This comment has been minimized.

Show comment
Hide comment
@harveyphan

harveyphan Nov 6, 2017

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

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

@laopunk

This comment has been minimized.

Show comment
Hide comment
@laopunk

laopunk Nov 16, 2017

you saved me a reboot, thanks a lot !

laopunk commented Nov 16, 2017

you saved me a reboot, thanks a lot !

@henning

This comment has been minimized.

Show comment
Hide comment
@henning

henning 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 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.

Show comment
Hide comment
@henning

henning 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.

henning 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.

Show comment
Hide comment
@PabloGBarcelo

PabloGBarcelo Nov 21, 2017

Great! it works like a charm!

Great! it works like a charm!

@gbmeuk

This comment has been minimized.

Show comment
Hide comment
@gbmeuk

gbmeuk 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

gbmeuk 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.

Show comment
Hide comment
@AndrewJHart

AndrewJHart Nov 28, 2017

this is fantastic! Thanks so much 👍

this is fantastic! Thanks so much 👍

@jhash

This comment has been minimized.

Show comment
Hide comment
@jhash

jhash Dec 12, 2017

I love you!

jhash commented Dec 12, 2017

I love you!

@Xyverz

This comment has been minimized.

Show comment
Hide comment
@Xyverz

Xyverz 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.

Xyverz 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.

Show comment
Hide comment
@McChubby

McChubby 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

McChubby 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.

Show comment
Hide comment
@imsrc21

imsrc21 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

imsrc21 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.

Show comment
Hide comment
@uyjulian

uyjulian 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 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.

Show comment
Hide comment
@uyjulian

uyjulian Apr 18, 2018

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

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.

Show comment
Hide comment
@ajain-bst

ajain-bst May 8, 2018

@uyjulian Thank you! It works!

@uyjulian Thank you! It works!

@kriskhaira

This comment has been minimized.

Show comment
Hide comment
@kriskhaira

kriskhaira Jun 10, 2018

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

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

@10fish

This comment has been minimized.

Show comment
Hide comment
@10fish

10fish 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.

10fish 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.

Show comment
Hide comment
@max-lobur

max-lobur 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

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.

Show comment
Hide comment
@will-dee

will-dee 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`

will-dee 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.

Show comment
Hide comment
@charafsalmi

charafsalmi 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

charafsalmi 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment