Your Mac has gone to sleep, but you're not finished with it yet. You can keep it awake with a built-in setting, a temporary Terminal command, or a menu-bar app. Start with the option that fits your setup, whether you need the computer working in the background or the screen lit too.
Keep a plugged-in MacBook awake
For a Mac laptop connected to external power, start with the automatic sleep setting. This path applies to macOS Sonoma 14, Sequoia 15, Tahoe 26, and macOS 27.
Connect your MacBook to power.
Open Apple menu > System Settings > Battery > Options.
Turn on Prevent automatic sleeping on power adapter when the display is off.
The display can still turn off while your Mac stays awake. The switch's availability depends on your model; if it's missing, use the temporary Terminal method below.
Change the Energy setting on a desktop Mac
Desktop Macs use a separate settings panel, and the sleep switch's availability depends on the model.
- 1.Open the Apple menu and select System Settings.
- 2.Choose Energy on macOS Sequoia 15, Tahoe 26, or macOS 27. On Sonoma 14, choose Energy Saver.
- 3.Turn on Prevent automatic sleeping when the display is off to keep the computer awake without keeping the display on. If the switch is missing, use the temporary Terminal method below.
Give the display more time before it turns off
Open Apple menu > System Settings > Lock Screen.
Open Turn display off on power adapter when inactive.
Select your desired timeout.
On a Mac laptop, open Turn display off on battery when inactive.
Select a timeout for unplugged use.
These controls set how long your Mac can be inactive, so pair them with a sleep prevention method when you need the Mac itself to keep working.
Use Terminal for a temporary keep-awake session
Just need your Mac awake for a while? The built-in caffeinate command prevents idle system sleep on battery or external power, with no app to install.
Open Applications > Utilities > Terminal.
Run caffeinate -i by typing it and pressing Return.
Leave the command running for as long as you need the Mac awake.
Press Control-C in Terminal to end the session.
To keep both the Mac and its display awake, run caffeinate -di instead.
For a session that ends automatically after one hour, run caffeinate -i -t 3600. The timeout is measured in seconds.
For a one-hour session with the screen kept on too, run caffeinate -di -t 3600 instead.
These commands prevent idle sleep. They don't override deliberate sleep, lid closure, battery exhaustion, or shutdown.
Remove a schedule that keeps putting your Mac to sleep
Canceling a sleep schedule stops sleep triggered by that schedule.
Open Terminal.
Run pmset -g sched to inspect scheduled power events.
To remove a recurring sleep schedule, run sudo pmset repeat cancel. This also removes associated recurring wake or startup events.
Authenticate as an administrator when prompted.
To remove one-time scheduled sleep events, run sudo pmset schedule cancelall. Only use this if you're ready to remove all one-time power events, including any wake or shutdown events you want to keep.
Authenticate as an administrator when prompted.
Start repeat sessions with a menu-bar app
Amphetamine offers manual, timed, app-based, and download-based sessions. Install it from its official Mac App Store listing, then click its menu-bar icon.
Choose Start New Session > Indefinitely for an ongoing session. For a timed session, start one from the same menu for a specified amount of time or until a specified time.
To tie the session to a task, choose Start New Session > While App Is Running and select the app, or choose Start New Session > While File is Downloading… and select the download.
To keep the screen on, set the session to prevent display sleep; Amphetamine lets you allow or prevent display sleep during a keep-awake session. Its listing does not explicitly certify macOS 27 compatibility.
Handle sleep when you close the lid
Closing a Mac laptop's built-in display normally puts it to sleep, even with idle sleep prevention running.
Leave the lid open while your work continues.
Use one of the sleep prevention methods above to keep the open laptop awake when idle.
For closed-display operation, the setup below applies to an M3 MacBook Air with macOS 14.3 or later, or an M3 MacBook Pro with macOS 14.6 or later. Other models require their own display compatibility instructions.
Keep the laptop open and unlocked during accessory setup.
Connect an external keyboard and mouse or trackpad. On an Apple silicon laptop, click Allow whenever accessory approval appears.
Connect external power.
Connect an external display, clicking Allow if requested.
Close the laptop display.
Apply an idle sleep prevention method as well if the closed-display setup needs to remain awake unattended.
Frequently Asked Questions
How can I check whether a keep-awake session is active?
Open Applications > Utilities > Terminal and run pmset -g assertions. The output shows current sleep-prevention assertions.
Is there a keyboard shortcut that permanently turns off sleep mode on a Mac?
There is no documented built-in key combination that permanently enables keep-awake. You can assign a custom keyboard shortcut to a prepared keep-awake shortcut that uses an app action, such as Lungo's.
Why does my session end even though I've prevented sleep?
Automatic logout is separate from sleep. Open Apple menu > System Settings > Privacy & Security > Advanced, then turn off Log out automatically after inactivity. This prevents automatic logout; it does not prevent system sleep.
Can IT keep a work-managed Mac awake?
Yes. Ask IT to configure an Energy Saver device-management policy with Disable Sleep enabled. Apple describes this setting as preventing the Mac from going to sleep.