Keep your Mac awake and stop it going to sleep
Quick answer
On a MacBook, open System Settings > Battery > Options… and turn on Prevent automatic sleeping on power adapter when the display is off. Then set longer display times in Lock Screen.
Why it happens
To save power, your Mac turns the display off after a while with no keyboard or mouse use, and then goes to sleep. Sleep pauses downloads, uploads and other long jobs. One switch keeps the Mac awake while the display is off, and the Lock Screen timers decide when the display turns off.
How to fix it
Open the Apple menu, choose System Settings, and click Battery in the sidebar. On an iMac, Mac mini, Mac Studio or Mac Pro, click Energy instead and go to step 3.
On a MacBook, click Options… and turn on Prevent automatic sleeping on power adapter when the display is off. Click Done. This works while the charger is plugged in.
Battery›Options…›Prevent automatic sleeping on power adapter when the display is off
On a desktop Mac, turn on Prevent automatic sleeping when the display is off in Energy.
Energy›Prevent automatic sleeping when the display is off
To keep the screen on longer too, click Lock Screen in the sidebar and choose longer times for Turn display off on power adapter when inactive, and on a MacBook, Turn display off on battery when inactive.
Lock Screen
Still not fixed?
On battery, a MacBook still sleeps when it's idle, even with the switch on. Plug in the charger for long jobs.
Closing a MacBook's lid puts it to sleep. To work with the lid closed, plug in power, connect a monitor and a keyboard or mouse, and close the lid only once the external screen shows your desktop.
If you want your Mac to wake for network tasks while it sleeps, such as file sharing, turn on Wake for network access in Battery > Options…, or in Energy on a desktop Mac.
Battery›Options…›Wake for network access
If your Mac still sleeps with these settings on and the charger connected, restart it and check the settings again. If it keeps sleeping or shutting down on its own, contact Apple Support.
Terminal
Open Terminal (Applications › Utilities), paste this line and press Return.
caffeinate -dimsuTo undo:
press Control-C in Terminal (or close the window) to stop caffeinatePro details
Keeps the Mac awake while the Terminal command runs; no sudo.
Questions people ask
How do I keep my MacBook from sleeping when plugged in?
Open Battery > Options… and turn on Prevent automatic sleeping on power adapter when the display is off.
How do I stop my iMac or Mac mini from going to sleep?
Open Energy in System Settings and turn on Prevent automatic sleeping when the display is off.
Will my Mac keep downloading when the screen turns off?
Yes, as long as it doesn't go to sleep. Turn on the prevent sleeping switch and keep a MacBook plugged in.
How do I keep my Mac screen on longer?
In Lock Screen settings, choose longer times for the Turn display off menus.
Related fixes
Glad it worked.
Sorry it didn't. Tell us what happened and we'll fix this page.
Get there in one click with PinSet.
Press ⌃ ⌥ Space and type “stop mac from sleeping”. PinSet opens Battery › Options… in System Settings and rings Prevent automatic sleeping on power adapter when the display is off. One of 2,400+ checked Mac fixes. Works offline.
7 fixes free · Works offline · macOS 26 and 27