When I close the lid of my Macbook I usually just assume it will go to sleep as expected. This one time, however, when I got back to my office and opened the lid I noticed the Mac was absurdly hot for a computer that has just been in sleep mode.
I decided to test it again and close the lid. To my surprise, the usual flashing light on the macbook didn’t flash at all. It just remained steadily lit. At first, I thought it was some hung app that was causing this so I decided to close every app and check if there was some process using the CPU heavily, but that wasn’t the case. I even tried rebooting and still that didn’t solve the problem. I checked the power settings and nothing pointed to it being the responsible for the sleep mode prevention.
After some googling I ended up discovering this neat command that allows checking the state of your power settings:
pmset -g assertions
This command displays a summary of power assertions. And according to the documentation: “These assertions may prevent system sleep or display”.
It’s worth a shot. This was the output:
Assertion status system-wide: PreventUserIdleDisplaySleep 0 PreventSystemSleep 1 PreventUserIdleSystemSleep 0 ExternalMedia 0 UserIsActive 0 ApplePushServiceTask 0 BackgroundTask 1 Listed by owning process: pid 477(helpd): [0x0000000c00000226] 00:54:25 BackgroundTask named: "com.apple.helpd.sdmbuilding" pid 1621(InternetSharing): [0x00000008000017bc] 00:00:02 DenySystemSleep named: "com.apple.InternetSharing"
Bingo! Internet Sharing! I totally forgot about it. Since I’ve been working with the Raspberry Pi lately, I had setup the mac to share its Internet with the mini computer. But I forgot to turn it off. And it makes perfect sense that it prevents the computer from sleeping because it’s sharing the resource that it may be currently used by some other computer.
After turning Internet Sharing off it all went back to normal. Just decided to share because it might happen to someone else.
Comments
Another thing that can prevent your mac from going to sleep, and this one did not show up in the assertions when I tried it, is any pending printing jobs. In my case it was a pending printing job in a network printer from my working place.
Once I went through the list of printers and managed to delete the pending jobs (I ended up deleting the printer too, as I no longer worked in that place) the mac was able to sleep again.
Thanks, Pascoal 🙂
Ouch, saved my day, thank you! =)