I have a need to turn USB power off (and on) using a script or a piece of software. Ideally it should be possible to turn each port off/on separately, but also turning power off/on from all ports at once is sufficient. The machine I am using is Mac Mini. Anyone has a solution for this?

By USB power I mean Vbus, the 5V/500mA connection. I understand that the data connection is also turned down and it is fine, but it is not enough for me that the data connection is down and Vbus remains powered. This need comes from the need to keep mobile phones constantly connected for automatic testing. Some device/battery combinations do not like to be constantly connected and batteries start swelling in less than a year.

I recognize that multiple variations of this question are around. So far no solution that I could use. I'll list here my findings so far:

  • it is possible to accomplish this by using external self powered USB HUB and controlling it's power. However, this is not an option for me (even quality hubs have caused other problems in my use).

  • it is possible to disable USB by removing .kext files. Among other sources it is explained in OS X Security configuration document. However this requires reboot and I am not sure if it really disables USB power or just data.

  • there are many claims that it just is not possible. However, OS X itself does it when it detects a device that consumes too much power, so there is at least hardware support. This error message is copied from /System/Library/Extension/IOUSBFamily.kext/Contents/Resources/English.lproj/Localizable.strings: "Unplug the device using too much power to re-enable USB devices." (of course I don't know if the disabling is done by turning off USB power, but I would assume it is natural action for the device that consumes too much of it).

  • it seems that on macbook the USB ports are normally powered even when the laptop is sleeping. While this is not solving my issue, it is kind of related.

The reason why I need this is that I have a test system where multiple devices are plugged in to a mac mini. The devices also charge over USB. It has turned out that if the device is connected all the time to a charger, it's battery is swollen in about a year, which makes the device unusable, insecure and potentially dangerous. Turning the power off when not needed, would significantly extend devices life.

  • Do you want to disable the whole port or just the power coming from the port. Your title is confusing.
    – Allan
    Apr 29, 2016 at 10:46
  • It is enough for me to disable the power. Due to the nature of USB it effectively disables the port. But it is not enough for me to disable the data flow/driver loading and keep the Vbus powered.
    – diidu
    Apr 29, 2016 at 11:06
  • 1
    It can happen. As I explain as part of my question, OS X does it when it detects a device that consumes too much current. Only, I don't know if there is any way to trigger that other than by inserting a device that consume too much power. -- I wish you were right about the phone being smart enough. Unfortunately I have now four different devices with a swollen battery, after being plugged in for a year. There is plenty of discussion on that on the Internet, so I won't go into details.
    – diidu
    Apr 29, 2016 at 11:26
  • 1
    And it is fine for me that USB no longer works. That is why I need a way to turn in on also.
    – diidu
    Apr 29, 2016 at 11:28
  • 1
    I think you misunderstand. It is ok for me to have "whole port" down. Or even the whole root hub and all USB ports in a mac mini. The only requirement I have is that the Vbus does not feed any power to the physically connected device and that I can turn the USB port/ports back up later.
    – diidu
    Apr 29, 2016 at 11:37

2 Answers 2


I spent a lot of time researching this problem some years ago - my conclusion is that it is simply not possible with the information available to us. The control of the power happens at a much lower level than the macOS kernel itself, so it is not just a question of configuring macOS or poking at the right kernel data structure. You have to modify firmware which is not possible for ordinary users.

The only working solution I found is to use a hub. This worked very well for me. If you have a hub that supports ganged power switching, you can easily turn off/on the power for each gang (set of ports). Similarly if you have a hub that supports per-port power switching, you can turn off/on each port on the hub individually.

You can download software for macOS to control the hub from here:


Note that this utility only supports controlling hubs that allow per-port power switching. The web site has a list of supported USB hubs.

Once I went with the hub solution, the hardest part really was finding a USB hub that supports ganged or per-port power switching. The actual software part is very easy.

  • 1
    It is incorrect to use ganged here. All USB hubs either don't support power switching, or support ganged switching (that is, for all ports at once), or support per-port (individual) power switching. uhubctl only supports per-port power switching, ganged hubs will not be recognized (I'm uhubctl author).
    – mvp
    Jul 2, 2019 at 8:22
  • I have edited to make it clearer what I meant. In this case it doesn't really matter because the question only required turning the whole hub off. I implemented a corresponding utility to uhubctl on Linux to solve a problem many years ago with a CAN-interface that would corrupt its own state, so I haven't got any in-depth experience with uhubctl - thanks for sharing the details!
    – jksoegaard
    Jul 2, 2019 at 8:46
  • Thanks for editing, but you really should remove word ganged - uhubctl doesn't support hubs with ganged power switching. Also, uhubctl cannot turn whole hub off - all ports yes, but hub itself will continue to work.
    – mvp
    Jul 2, 2019 at 8:56
  • I know it doesn't support it - I wrote that in the answer. However other utilities might. And yes, I know it doesn't turn the whole hub off - it turns all the ports off - that's also what I wrote.
    – jksoegaard
    Jul 2, 2019 at 9:02
  • Is this still not possible in 2021? (I opened a similar question, but it was closed and I was referred to this one.) @jksoegaard
    – nisc
    Jun 27, 2021 at 5:15

The way that I did it was to open my USB cable, cut the red VBUS wire, and then hook it up to a bench top PSU that I can control using python.

You must log in to answer this question.

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