If there is a process that is preventing sleep (rather than a bug in the sleep implementation), you can use "pmset -g" in a terminal window to list the process that is doing that. This is covered over on superuser.
Here is an an example on my system. First, with nothing preventing sleep:
$ pmset -g assertions | egrep '(PreventUserIdleSystemSleep|PreventUserIdleDisplaySleep)'
PreventUserIdleDisplaySleep 0
PreventUserIdleSystemSleep 0
$
Then I start music in iTunes:
$ pmset -g assertions | egrep '(PreventUserIdleSystemSleep|PreventUserIdleDisplaySleep)'
PreventUserIdleDisplaySleep 0
PreventUserIdleSystemSleep 1
pid 264: [0x0000012c00000108] PreventUserIdleSystemSleep named: "com.apple.audio.'AppleHDAEngineOutput:1B,0,1,2:0'.noidlesleep"
pid 95390: [0x0000012c0001749e] PreventUserIdleSystemSleep named: "Nameless (via IOPMAssertionCreate)"
With the addressbook
preventing the sleep I used the following procedure to fix it on my MBA 10.9.2
As always it is recommended to Back up all data.
Triple-click anywhere in the line of text below on this page to select it:
~/Library/Caches/com.apple.AddressBookSourceSync
Right-click or control-click the highlighted line and select
Services ▹ Reveal
from the contextual menu.* A folder should open with an item selected. Move the selected item to the Trash.
Log out, log back in, and test. If there's no change, go to the next step.
*If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
Go ▹ Go to Folder...
from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.
Step 2
If you use iCloud, uncheck the box marked Contacts in the iCloud preference pane. Press return to confirm, or click Keep on Mac in the dialog that opens.
Step 3
From the list of groups on the left side of the Contacts window, select All On My Mac. If that group doesn't exist or is empty, skip this step. Otherwise, from the menu bar, select
File ▹ Export ▹ Export vCard
Save the exported contacts to the Desktop.
Step 4
Quit Contacts. Reveal the following item in the Finder as you did in Step 1:
~/Library/Application Support/AddressBook
Move the selected folder to the Desktop, leaving the window open for now.
Step 5
Launch Contacts. Your contacts will be gone. If you took Step 3, then double-click the file you created in that step and confirm that you want to import from it. Your contacts will reappear.
Step 6
If you took Step 2, reverse it. Test. If the issue is resolved, delete the AddressBook folder and the vCard file on the Desktop and close the open folder window.
Otherwise, quit Contacts again and put the AddressBook folder back where it was, overwriting the newer one that will have been created in its place.
Courtesy. https://discussions.apple.com/people/Linc%20Davis
Best Answer
InsomniaX works perfectly on my MBP 13" 2015. I am using macOS Sierra 10.12.
There's also an app called NoSleep, but it hasn't been updated in years, only use it if you're on older OSX like Mavericks or Yosemite.. I wouldn't recommend using it on Sierra..
UPDATE: 1st FEB, 2020 InsomniaX is not being mantained anymore & you SHOULD NOT use it. No sleep is a better option until MacOS Mojave. Haven't tested any of these with MacOS Catalina. If anyone has tested with Catalina, let us know in the comments.