MacBook does not sleep when lid is closed

A lack of wake reason entries suggests your Mac is never fully sleeping. The sleep mechanism has started but never completes.

Use the following Terminal command to view a detailed log showing your Mac's power history:

pmset -g log

You will see a list of entries in form:

 * Domain: applicationresponse.slowresponse
 - Message: PMConnection AirPort configd plug-in com.apple.powermanagement.applicationresponse.slowresponse 1399 ms
 - Time: 13/03/2012 12:27:53 CET 
 - Signature: AirPort configd plug-in
 - UUID: AB482838-2D6E-0000-0000-14BF53E20000
 - Result: Noop
 - Response time (ms): 1399

Look out for applications that may be keeping your Mac awake and active. Applications and other processes can keep your Mac awake if they are providing a service, such as file sharing or remote access. However, processes should be forced asleep after 30 seconds on lid close.

The behaviour you are seeing suggests a kernel extension or IOKit problem. User level processes can not block sleep when instigated by the user.

Do you have any utilities installed that install kernel extensions (kext)? These might include screen recording or audio capture tools; utilities than need low level access to your Mac.


It's worth repairing your permissions, if you haven't already done that. Permissions errors have caused a wide range of bizarre problems in the Lion upgrade.

It also might help to generate ideas if you can determine if the problem is system-wide or user-specific. Do that by creating a new, pristine user account and using that to see if the problem persists.

A genuine "clean install" of Lion is still a debated procedure, but some people who exhaust all other diagnostic possibilities have ended up going that route with good success. I hope your problem is more straightforward than that!

--

EDIT:

I gather that booting in Safe Mode solves the problem, but creating a new user doesn't. That strongly suggests the problem is something you're loading at startup. Good news is that this should be straightforward to fix.

Your experiments so far suggest that whatever is causing the problem is in your /Library directory, and not in your User folder. A manageably small list of things is disabled during a Safe Mode startup, including /System/Library/Extensions, /Library/StartupItems, and notably, any fonts outside of /System/Library/Fonts. Your problem must be something in one of these locations.

I have a funny feeling that you may have a corrupted font, since this is a common problem that manifests in odd ways. You could try the troubleshooting strategies described here, which essentially consist of validating the fonts using the Font Book utility (included with Mac OS X), clearing out the font cache, and removing any duplicates.

If fonts aren't the problem, this earlier discussion has good information about how to go about disabling errant startup extensions and login items. It's a matter of taking everything suspicious out, and adding things back bit-by-bit until you find your culprit.

I think you're close to the solution, please do let us know when you've cracked it.


Run the following command:

pmset -g assertions

and list all system-wide assertions preventing your system sleep along with their processes.

Whenever processes override any system power settings, pmset will list those processes and their power assertions in -g and -g assertions.

Normally when nothing is stopping macOS from going to sleep, you should have all 0. If you have 1 instead of 0 somewhere, the line could explain the reason of it.

Source: Display Sleep not working.

You can also check by the following command:

pmset -g | grep -w sleep

For example:

Idle sleep preventers: IODisplayWrangler

If you found a specific reason why the sleep isn't working, and still didn't help, please google or ask a new question with output specific details. Or simply restart your computer and see if that helps.



Troubleshooting

  • Check for any processes appearing in system-wide and kernel assertions via pmset -g assertions and kill or restart one which you think may be the cause of the issue.
  • Disable WiFi or any other network which may appear in the kernel assertions list.

    $ pmset -g assertions
    // ...
    Listed by owning process:
       pid 343(Google Chrome): [0x0000003600018115] 05:02:36 NoIdleSleepAssertion named: "WebRTC has active PeerConnections" 
    // ...
    Kernel Assertions: 0x100=MAGICWAKE
       id=501  level=255 0x100=MAGICWAKE mod=01/01/1970, 01:00 description=en0 owner=en0
    
  • Disconnect any external devices (USB, SD cards, bluetooth devices, etc.).

    $ pmset -g assertions
    Assertion status system-wide:
    // ...
       ExternalMedia                  1
    // ...
    Listed by owning process:
       pid 73(powerd): [0x0000000600088007] 05:03:24 ExternalMedia named: "com.apple.powermanagement.externalmediamounted" 
    // ...
    
  • Run the assertion logs by: pmset -g assertionslog, close the lid and read the logs.

  • If you expect hibernation instead of standard sleep mode, use pmset to verify hibernatemode, by default it should be set to 3:

    pmset -g | grep -w hibernatemode
    

    Otherwise set to 3 (you can also consider 25):

    sudo pmset -a hibernatemode 3
    

    See: man pmset and for further details.

    Warning: We do not recommend modifying hibernation settings. Any changes you make are not supported. If you choose to do so anyway, we recommend using one of these three settings. For your sake and mine, please don't use anything other 0, 3, or 25.

    hibernatemode = 0 (binary 0000) by default on supported desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.

    hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image.

    hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.

  • To check the current state of your display (below 4 means it's already in a sleep mode):

    pmset -g powerstate IODisplayWrangler
    
  • To put displays to sleep from the command-line, run:

    pmset displaysleepnow
    # or:
    osascript -e 'tell app "System Events" to sleep'
    

    To wake up a display:

    caffeinate -u -t 1
    

See also: pmset - Sample usage, How to Hibernate a Mac.


Have you tried this fix from the Apple forum. The uses fixed the issue by uninstalling a printer driver which he found out to be causing the issue.

You might also try disabling the "Wake for Network Access" option