I want to leave my Mac awake overnight so it syncs 4GB of data from Dropbox. I need to prevent the machine from going to sleep because that pauses the Dropbox sync

I've been using Caffeine to keep the computer awake, but it also keeps the computer unlocked which is insecure.

I need a method to keep my Mac awake (so that Dropbox can sync overnight) but also locked (so no one can read my email). It'd be great if this method also turned off the screen (to preserve power), but honestly that's not even 100% necessary.

  • 3
    In Yosemite, there is an option named *Prevent computer from sleeping automatically when the display is off" in System Preferences > Energy Saver.
    – Daniel
    Dec 9 '15 at 13:13
  1. In System Preferences > Energy Saver, check the box for "Prevent computer from sleeping automatically when the display is off" (on laptops, this is under the Power Adapter tab)
  2. In System Preferences > Security & Privacy, check the box for "Require password after sleep or screen saver begins" and set the delay in the dropdown menu to "immediately"

Now, you can hit command-option-power to turn off the display without sleeping the computer, and doing anything that turns on the display (like hitting a key or clicking a mouse button) will prompt you for your account password.

On newer macs without the eject key, please use control-shift+power instead.

  • 21
    Note this is control-shift-power on newer macs without an eject key
    – dstarh
    Apr 18 '14 at 17:20
  • 5
    With external keyboard without the eject key, one can check the Show keychain status in menu bar option in Keychain Access App's Preferences. Then you will be able to Lock Screen in the menu bar by clicking the lock icon.
    – Mengdi Gao
    Sep 1 '14 at 14:45
  • 3
    If I change the setting to never go to sleep, will the MacBook still go to sleep if I manually tell it to? Mar 20 '15 at 12:53
  • 5
    So the computer is still awake when the display is off and locked? Does it keep working when in the password prompt window? And this would apply to keeping scripts (python and php in terminal) running?
    – alex9311
    Feb 18 '16 at 11:31
  • 1
    Yes. Locking access to your device and/or keychain does not stop other processes from running.
    – mikezter
    Feb 27 '16 at 12:44

Not sure when it was first available, but on MacOS High Sierra 10.13.4 you can go to Apple (top left) > Lock Screen or press control-command-q to activate the lock screen.

You should also do the first step in @daGUY's answer

In System Preferences > Energy Saver, check the box for "Prevent computer from sleeping automatically when the display is off" (on laptops, this is under the Power Adapter tab)

  • I don't appear to have this option under High Sierra. Did it move somewhere else?
    – intuited
    Jun 1 '20 at 10:57
  • on catalina it's still there, do the hotkeys work for you?
    – wyu
    Jun 2 '20 at 19:34
  • yeah, I always lock with Command-Shift-Q but sometimes it suspends the machine—I think this happens unless there's network activity.
    – intuited
    Jun 3 '20 at 13:47
  • command shift Q logs you out, it's a different action from just showing the lock screen which is control command q. Also do you have "Prevent computer from sleeping automatically when the display is off" checked?
    – wyu
    Jun 5 '20 at 14:31
  • Wait, actually I just realized that I use CTRL-CMD-Q. I don't have that option in Preferences -> Energy Saver.
    – intuited
    Jun 6 '20 at 18:15

On MacOs Mojave the accepted answer didnt work for me. What worked is to use free app Amphetamine. After app installation select the option Indefinitely. Now you can lock the screen and it will not go to sleep.

enter image description here


You can use KeepingYouAwake. It is a free and lightweight menu bar utility for macOS (Version 10.10 and newer) that can prevent your Mac from entering sleep mode for a predefined duration or as long as it is activated.

It can be easily installed using Homebrew cask by running:

brew cask install keepingyouawake

It is an alternative to widely popular tool Caffeine from Lighthead Software. Caffeine hasn't been updated in a while. KeepingYouAwake's icons are Retina-compatible and do look nice in the dark themed menu bar.

Once you have activated KeepingYouAwake, you can simply lock the screen (by pressing Control + Command + q), turn down the screen brightness and remain assured that the system won't go to sleep!


Wimoweh $$ will automatically keep your mac awake when user selectable processes are running and will control the display sleeping (or not) as well.

  • 2
    We like answers to be more than just a single line. Ideally, you want to explain why your answer is *right." It also helps to provide links, citations, and/or screen shots. Please review our help section How to Answer on writing good answers to questions
    – Allan
    Jun 27 '16 at 18:48

If you don't use an Apple keyboard, you can lock it with the mouse by selecting your name in the right-side of the menubar and click Login Window...


There is no need for external utilities — you can do it using the ootb Apple command line utilities:

# prevent idle sleep while plugged in
pmset noidle

# (prefix the command with `sudo` or get a root session 
# by typing `sudo -i` followed by your password)

# disable sleep (while plugged in or on battery)
pmset -a disablesleep 1
# after running this command you'll notice that the Sleep option
# under the Apple menu is grayed out 

# re-enable sleep
pmset -a disablesleep 0

# prevent sleep for 1 hour while on battery (this must be run under a root session with `sudo -i`)
pmset -a disablesleep 1 && sleep 3600 && pmset -a disablesleep 0

❗️❗️❗️ WARNING: After you disable sleep with sudo pmset -a disablesleep 1 your mac will stop sleeping and the Sleep option under the apple menu will stay greyed out even after a reboot and even on battery power. You MUST run sudo pmset -a disablesleep 0 if you want to restore normal sleep.

For more usage info use man pmset and man caffeinate in your terminal. Keep in mind that caffeinate only works when running on AC power.


You can try "Lock Me Now" app from the app store. It gives a pretty neat way to lock the mac.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .