Stop process from preventing sleep on OS X

I run a MacBook Pro with OS X 10.11. I've noticed the machine hasn't slept well last night. There were events logged every couple of seconds in system.log throughout the entire night that the lid was closed.

I think it might be that two processes are preventing sleep while on A/C.

# pmset -g
System-wide power settings:
[...]
sleep                10 (sleep prevented by UserEventAgent, UserEventAgent)

Can I stop these processes (or any other process) from preventing sleep?


There are dozens of things that can prevent sleep built into macOS, and third party software can also disable sleep.

The first troubleshooting step is to run this command in Terminal:

pmset -g assertions

That will list the reasons your Mac is not currently asleep. Normally running on battery power you should get:

Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     0
   NetworkClientActive            0

[further details removed for brevity]

Which means the only reason your mac isn't sleeping is due to user activity on the mouse/keyboard.

If you see something else (like PreventUserIdleSystemSleep) then your mac probably won't sleep at all and you should read the other details provided by pmset -g assertions to investigate further.


UserEventAgent suggests an input device was in active use. This may be a faulty mouse, keyboard, or other input device like a gamepad.

Try disconnecting all your externally connected devices and seeing if this behaviour continues.

Another cause may be a pet or vibrations causing a device to register movement.

Is Wake for network access enabled? See System Preferences > Energy Saver for this setting. Waking for network access will occasionally wake a sleeping Mac to examine and maintain the network environment.

Alternatively, consider using a third party tool to help put your Mac to sleep despite power assertions.


In my case it was because I was running the iPhone emulator that comes with XCode. Closing the emulator down removed sleep prevented by UserEventAgent.

I only had one occurrence of UserEventAgent though. When I ran pmset -g I got this:

~$ pmset -g
System-wide power settings:
Currently in use:
 [...]
 sleep                10 (sleep prevented by UserEventAgent)

In my case the culprit was a Bluetooth keyboard with low batteries. Recharging the batteries fixed the problem.

Actually I got what I deserved because I ignored the "Keyboard batteries low" notifications for a week. My MacMini got so upset (they don't like being neglected) that she could not sleep... :-)