MacOS – MacBook Pro wakes immediately after sleeping

macbook promacossleep-wake

When I put my MacBook Pro to sleep, it will immediately wake up again after ~5 seconds, then go to sleep again and keep on sleeping and waking.
This happens no matter if I close the lid or use the  -> Sleep menu item.

The wake reason specified in the syslog, is XHC1, which I read was related to Bluetooth. I have Bluetooth disabled on my Mac and I also have "Allow Bluetooth devices to this computer" disabled and all the sharing services in System Preferences are disabled.

The only thing I have physically connected to my Mac is the charger, even though the syslog mentions the awakening might be caused by an USB device.
If my USB plugs are damaged, can I disable wake for USB activity?

Here is the syslog for one sleep/wake cycle:

Oct 21 01:18:26 Tyilos-MBP kernel[0] <Debug>: sleep
Oct 21 01:18:26 Tyilos-MBP kernel[0] <Debug>: Wake reason: XHC1
Oct 21 01:18:30 Tyilos-MBP kernel[0] <Debug>: AirPort_Brcm43xx::powerChange: System Wake - Full Wake/ Dark Wake / Maintenance wake
Oct 21 01:18:30 Tyilos-MBP kernel[0] <Debug>: Previous Sleep Cause: 5
Oct 21 01:18:30 Tyilos-MBP kernel[0] <Debug>: USB (XHCI Root Hub USB 2.0 Simulation):Port 6 on bus 0xa connected or disconnected: portSC(0xf0202e0)
Oct 21 01:18:30 Tyilos-MBP.local configd[18] <Notice>: network changed: v4(en1-:192.168.1.101) DNS- Proxy- SMB
Oct 21 01:18:30 Tyilos-MBP.local mDNSResponder[39] <Error>: DeregisterInterface: Frequent transitions for interface en1 (192.168.1.101)
Oct 21 01:18:30 Tyilos-MBP kernel[0] <Debug>: An Unknown USB Device (Port 2 of Hub at 0x15000000), may have caused a wake by being connected
Oct 21 01:18:30 Tyilos-MBP kernel[0] <Debug>: TBT W (1): 0 [x]
Oct 21 01:18:31 Tyilos-MBP kernel[0] <Debug>: MacAuthEvent en1   Auth result for: 84:1b:5e:dd:67:ec  MAC AUTH succeeded
Oct 21 01:18:31 Tyilos-MBP kernel[0] <Debug>: wlEvent: en1 en1 Link UP virtIf = 0
Oct 21 01:18:31 Tyilos-MBP kernel[0] <Debug>: AirPort: Link Up on en1
Oct 21 01:18:31 Tyilos-MBP kernel[0] <Debug>: en1: BSSID changed to 84:1b:5e:dd:67:ec
Oct 21 01:18:31 Tyilos-MBP kernel[0] <Debug>: en1::IO80211Interface::postMessage bssid changed
Oct 21 01:18:31 Tyilos-MBP kernel[0] <Debug>: AirPort: RSN handshake complete on en1
Oct 21 01:18:32 Tyilos-MBP kernel[0] <Debug>: Graphics suppressed 2580 ms
Oct 21 01:18:32 Tyilos-MBP.local configd[18] <Notice>: network changed: v4(en1+:192.168.1.101) DNS+ Proxy+ SMB
Oct 21 01:18:32 Tyilos-MBP.local mDNSResponder[39] <Error>: mDNS_RegisterInterface: Frequent transitions for interface en1 (FE80:0000:0000:0000:5E96:9DFF:FE70:8BCB)
Oct 21 01:18:32 Tyilos-MBP.local mDNSResponder[39] <Error>: mDNS_RegisterInterface: Frequent transitions for interface en1 (192.168.1.101)
Oct 21 01:18:32 Tyilos-MBP.local UserEventAgent[11] <Notice>: Captive: en1: Not probing 'AAA' (protected network)
Oct 21 01:18:32 Tyilos-MBP.local configd[18] <Notice>: network changed: v4(en1!:192.168.1.101) DNS Proxy SMB
Oct 21 01:18:34 Tyilos-MBP.local airportd[19062] <Error>: _doAutoJoin: Already associated to “AAA”. Bailing on auto-join.
Oct 21 01:18:35 Tyilos-MBP kernel[0] <Debug>: HID tickle 5265 ms
Oct 21 01:18:35 Tyilos-MBP.local loginwindow[42] <Error>: ERROR | -[LWScreenLock(Private) screenIsLockedTimeExpired:] | No lock state found, use built in check
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: handle_will_sleep_auth_and_shield_windows: no lock state data
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: Created shield window 0x9be for display 0x003f003d
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: handle_will_sleep_auth_and_shield_windows: no lock state data
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: Created shield window 0x9bf for display 0x003f003e
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: handle_will_sleep_auth_and_shield_windows: no lock state data
Oct 21 01:18:35 Tyilos-MBP.local KeyRemap4MacBook[371] <Warning>: observer_NSWorkspaceScreensDidWakeNotification
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: Created shield window 0x9c0 for display 0x003f003f
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Warning>: handle_will_sleep_auth_and_shield_windows: no lock state data
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Error>: CGXGetWindowOwner: Invalid window 2494
Oct 21 01:18:35 Tyilos-MBP.local HyperDock Helper[18694] <Error>: CGSGetWindowOwner
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Error>: CGXGetWindowOwner: Invalid window 2494
Oct 21 01:18:35 Tyilos-MBP.local HyperDock Helper[18694] <Error>: CGSGetWindowOwner
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Error>: CGXGetWindowOwner: Invalid window 2495
Oct 21 01:18:35 Tyilos-MBP.local HyperDock Helper[18694] <Error>: CGSGetWindowOwner
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Error>: CGXGetWindowOwner: Invalid window 2495
Oct 21 01:18:35 Tyilos-MBP.local HyperDock Helper[18694] <Error>: CGSGetWindowOwner
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Error>: CGXGetWindowOwner: Invalid window 2496
Oct 21 01:18:35 Tyilos-MBP.local HyperDock Helper[18694] <Error>: CGSGetWindowOwner
Oct 21 01:18:35 Tyilos-MBP.local WindowServer[94] <Error>: CGXGetWindowOwner: Invalid window 2496
Oct 21 01:18:35 Tyilos-MBP.local HyperDock Helper[18694] <Error>: CGSGetWindowOwner
Oct 21 01:18:35 Tyilos-MBP.local loginwindow[42] <Error>: resume called when there was already a timer
Oct 21 01:18:35 Tyilos-MBP.local KeyRemap4MacBook[371] <Warning>: observer_NSWorkspaceDidWakeNotification
Oct 21 01:18:35 Tyilos-MBP.local airportd[19062] <Error>: _doAutoJoin: Already associated to “AAA”. Bailing on auto-join.
Oct 21 01:18:35 Tyilos-MBP kernel[0] <Debug>: en1: BSSID changed to 84:1b:5e:dd:67:ec
Oct 21 01:18:37 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19066] <Warning>: Will terminate until reinvoked again by launchd.
Oct 21 01:18:40 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19109] <Warning>: Set up watching for containers directory at URL file://localhost/Users/Tyilo/Library/Containers/
Oct 21 01:18:55 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19109] <Warning>: Will terminate until reinvoked again by launchd.
Oct 21 01:19:00 Tyilos-MBP.local coreaudiod[308] <Notice>: Disabled automatic stack shots because audio IO is active
Oct 21 01:19:00 Tyilos-MBP.local coreaudiod[308] <Notice>: Enabled automatic stack shots because audio IO is inactive
Oct 21 01:19:03 Tyilos-MBP.local activitymonitord[19118] <Notice>: sending signal: 9 to pid: 60
Oct 21 01:19:03 Tyilos-MBP com.apple.launchd[1] (org.macports.ddclient[60]) <Notice>: Exited: Killed: 9
Oct 21 01:19:08 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19126] <Warning>: Set up watching for containers directory at URL file://localhost/Users/Tyilo/Library/Containers/
Oct 21 01:19:16 Tyilos-MBP.local coreaudiod[308] <Notice>: Disabled automatic stack shots because audio IO is active
Oct 21 01:19:17 Tyilos-MBP.local coreaudiod[308] <Notice>: Enabled automatic stack shots because audio IO is inactive
Oct 21 01:19:17 Tyilos-MBP.local coreaudiod[308] <Notice>: Disabled automatic stack shots because audio IO is active
Oct 21 01:19:17 Tyilos-MBP.local coreaudiod[308] <Notice>: Enabled automatic stack shots because audio IO is inactive
Oct 21 01:19:23 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19126] <Warning>: Will terminate until reinvoked again by launchd.
Oct 21 01:19:25 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19127] <Warning>: Set up watching for containers directory at URL file://localhost/Users/Tyilo/Library/Containers/
Oct 21 01:19:35 Tyilos-MBP.local Airmail[297] <Warning>: [***ERROR***] ERROR IDLE asgerdrewsen@gmail.com Error Domain=MCOErrorDomain Code=1 "A stable connection to the server could not be established." UserInfo=0x7ff133b23e50 {NSLocalizedDescription=A stable connection to the server could not be established.}
Oct 21 01:19:40 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19127] <Warning>: Will terminate until reinvoked again by launchd.
Oct 21 01:20:08 Tyilos-MBP.local SIMBL Enabler for Sandboxed Apps[19131] <Warning>: Set up watching for containers directory at URL file://localhost/Users/Tyilo/Library/Containers/
Oct 21 01:20:16 Tyilos-MBP.local WindowServer[94] <Error>: CGXSetWindowBackgroundBlurRadius: Invalid window 0xffffffff
Oct 21 01:20:16 Tyilos-MBP.local loginwindow[42] <Error>: find_shared_window: WID -1
Oct 21 01:20:16 Tyilos-MBP.local loginwindow[42] <Error>: CGSGetWindowTags: Invalid window 0xffffffff
Oct 21 01:20:16 Tyilos-MBP.local loginwindow[42] <Error>: find_shared_window: WID -1
Oct 21 01:20:16 Tyilos-MBP.local loginwindow[42] <Error>: CGSSetWindowTags: Invalid window 0xffffffff
Oct 21 01:20:16 Tyilos-MBP.local WindowServer[94] <Warning>: Created shield window 0x9d5 for display 0x04273140
Oct 21 01:20:16 Tyilos-MBP.local WindowServer[94] <Warning>: device_generate_desktop_screenshot: authw 0x7ff05a470d30(2000), shield 0x7ff05b125480(2001)
Oct 21 01:20:16 Tyilos-MBP.local WindowServer[94] <Warning>: device_generate_lock_screen_screenshot: authw 0x7ff05a470d30(2000), shield 0x7ff05b125480(2001)
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: hibernate image path: /var/vm/sleepimage
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: AirPort_Brcm43xx::powerChange: System Sleep 
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: hibernate_alloc_pages act 624795, inact 515514, anon 6492, throt 0, spec 415907, wire 446254, wireinit 153624
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: hibernate_setup(0) took 0 ms
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: sizeof(IOHibernateImageHeader) == 512
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: kern_open_file_for_direct_io(0) took 4 ms
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: Opened file /var/vm/sleepimage, size 17179869184, partition base 0x0, maxio 2000000 ssd 0
Oct 21 01:20:16 Tyilos-MBP kernel[0] <Debug>: hibernate image major 1, minor 0, blocksize 512, pollers 5
Oct 21 01:20:18 Tyilos-MBP kernel[0] <Debug>: en1: BSSID changed to 84:1b:5e:dd:67:ec
Oct 21 01:20:18 Tyilos-MBP kernel[0] <Debug>: wlEvent: en1 en1 Link DOWN virtIf = 0
Oct 21 01:20:18 Tyilos-MBP kernel[0] <Debug>: AirPort: Link Down on en1. Reason 8 (Disassociated because station leaving).
Oct 21 01:20:18 Tyilos-MBP kernel[0] <Debug>: en1::IO80211Interface::postMessage bssid changed
Oct 21 01:20:18 Tyilos-MBP kernel[0] <Debug>: hibernate_page_list_setall(preflight 0) start 0xffffff820dfdd000, 0xffffff820e05d000
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: hibernate_page_list_setall time: 941 ms
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: pages 1975335, wire 412665, act 435370, inact 4559, cleaned 0 spec 285, zf 6424, throt 0, could discard act 176868 inact 504499 purgeable 19042 spec 415623 cleaned 0
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: hibernate_page_list_setall found pageCount 859303
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: IOHibernatePollerOpen, ml_get_interrupts_enabled 0
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: IOHibernatePollerOpen(0)
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: encryptStart 13320
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: IOPolledInterface::checkForWork[5] 0xe00002eb
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: PMStats: Hibernate write took 2 ms
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: all time: 2 ms, comp bytes: 0 time: 0 ms 0 Mb/s, crypt bytes: 184032 time: 0 ms 405 Mb/s, 
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: image 0 (0%), uncompressed 0 (0), compressed 0 (0%), sum1 8c6cac84, sum2 0
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: wired_pages_encrypted 0, wired_pages_clear 0, dirty_pages_encrypted 0
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: hibernate_write_image done(e00002eb)
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: sleep
Oct 21 01:20:20 Tyilos-MBP kernel[0] <Debug>: Wake reason: XHC1

Update

It also happens when booting to the Recovery HD and when booting in safe mode, so it seems like it must be a hardware problem.
It also doesn't matter if the two USB ports on my Mac have something connected to them or not.

Update 2

XHC1 and port 0xa means "USB 3.0 Hi-Speed/SuperSpeed Bus" as seen in the screenshots below:

enter image description here
enter image description here

Update 3

It only happens when the power adapter is plugged in, so unplugging the adapter before sleeping works perfectly.

Best Answer

It appears this has to do with a Bluetooth Device connecting and waking up your computer.

Source: https://discussions.apple.com/thread/4405043?start=0&tstart=0