iMac will not sleep

I have had an issue with my iMac sleeping for the past few days and had to shut it down last night to keep it from waking up as the hum from the machine drives me crazy. My machine does not wake fully: There is no display but the fans turn back on and just run endlessly.

Here’s what I did to determine what is waking my machine.

In Lion (OS X 10.7) fire up terminal and type:

syslog |grep -i "Wake reason"

You will get something to the effect of this:

Jan 11 14:37:36 imac kernel[0] : Wake reason: UHC4
Jan 12 16:26:15 imac kernel[0] : Wake reason: UHC4
Jan 12 17:05:52 imac kernel[0] : Wake reason: UHC4
Jan 12 18:55:58 imac kernel[0] : Wake reason: UHC4
Jan 13 07:53:58 imac kernel[0] : Wake reason: UHC4
Jan 14 09:35:07 imac kernel[0] : Wake reason: UHC4
Jan 14 13:20:19 imac kernel[0] : Wake reason: UHC4
Jan 14 15:29:27 imac kernel[0] : Wake reason: UHC4
Jan 14 23:01:55 imac kernel[0] : Wake reason: UHC4
Jan 15 08:47:20 imac kernel[0] : Wake reason: UHC4
Jan 15 19:53:30 imac kernel[0] : Wake reason: UHC4
Jan 16 08:35:03 imac kernel[0] : Wake reason: UHC4
Jan 16 14:58:12 imac kernel[0] : Wake reason: UHC4
Jan 17 22:17:45 imac kernel[0] : Wake reason: UHC4

It would seem that UHC4 is our culprit but we don’t really have any information about what UHC4 is so we have to dig a little deeper.

In Console, check the kernel.log and filter using “wake”.

You will see something like this:

Jan 14 15:29:27 imac kernel[0]: Wake reason: UHC4
Jan 14 15:29:27 imac kernel[0]: The USB device BRCM2046 Hub (Port 1 of Hub at 0x1a000000) may have caused a wake by issuing a remote wakeup (2)
Jan 14 15:29:27 imac kernel[0]: The USB device Bluetooth USB Host Controller (Port 1 of Hub at 0x1a100000) may have caused a wake by issuing a remote wakeup (3)

UHC4 appears to be my BT Keyboard. Checking more, all the recorded times look legit and it would seem that this is not the rogue waking that I am researching but me manually bringing the machine out of sleep by tapping the spacebar. What’s stranger, it does not seem that my Macintosh is recording the other waking periods that I am complaining about.

To the web. After more research I came across this post and tried doing the steps here.
Ultimately, disabling all of my sharing preferences and enabling them fixed the problem.

So… if your Mac is waking randomly and you’re getting no display then try the “sharing fix” first. If your machine is waking fully, display and all, try some of the steps above to determine the cause and you should be a few steps closer to resolving the issue.