Mac sleep guide

How to keep your Mac awake, for as long as you need.

A Mac sleeps to save power, which is the wrong thing when a long job is running or you plan to connect to it later. Here are the ways to stop it, from a settings switch to one line in Terminal.

Updated · macOS 15 or later · Windows 10 or 11 · Linux with Xorg · iOS 18 or iPadOS 18 or later · Android 10 or later

Prevent sleep in System Settings

  1. 1

    Open System Settings

    Choose System Settings from the Apple menu.

  2. 2

    On a MacBook, go to Battery, then Options

    Turn on Prevent automatic sleeping on power adapter when the display is off. The Mac now stays awake while it is plugged in, even after the screen goes dark.

  3. 3

    On a desktop Mac, go to Energy

    A Mac mini, iMac or Mac Studio keeps its sleep setting there, along with Start up automatically after a power failure.

  4. 4

    Check what is set

    Open Terminal and run pmset -g. It shows the current power settings.

This is the set-and-forget method. It lasts until you change it back, and on a MacBook it applies only on the power adapter.

Keep a Mac awake from Terminal with caffeinate

caffeinate is a command built into macOS. It holds the Mac awake for as long as it runs, and lets go when you press Control-C.

The caffeinate commands
CommandWhat it does
caffeinate -dKeeps the display awake
caffeinate -iPrevents idle sleep
caffeinate -sPrevents sleep while the Mac is on power
pmset -gShows the current power settings, so you can check your work

Use it for one-off jobs: a long download, an export, a backup. Press Control-C when the job is done and the Mac goes back to its normal schedule.

The truth about a closed lid

None of the above keeps a MacBook awake once you close it. Closing the lid puts a MacBook to sleep, and caffeinate does not change that.

There is one exception: a MacBook stays awake with the lid closed when it is on power and has an external display attached.

If you have no display to plug in, leave the lid open and turn the screen brightness down.

An app for it: Amphetamine

If you would rather click than type, Amphetamine is a free app on the Mac App Store that stops a Mac from sleeping. You can switch it on by hand or have it start on triggers you set.

For remote access: Keep Active in Anywhere

If your Mac must stay awake because you want to reach it from somewhere else, the remote desktop app can handle it. Anywhere has a setting called Keep Active, with three choices.

  • Never leaves sleep to macOS.
  • On power keeps the Mac awake while it is plugged in.
  • Always keeps it awake on battery too, down to a battery level you choose. The default is 10%.

Keep Active can also nudge the pointer every minute during the days and hours you choose, so the screen saver and the lock screen don't appear. Anywhere never locks the Mac itself.

The lid rule still applies: a MacBook normally sleeps when its lid closes, so leave it open. More on reaching a Mac remotely.

Waking a sleeping Mac from somewhere else

It is tempting to let the Mac sleep and wake it when you need it. In practice that doesn't hold up outside your home.

macOS has a setting called Wake for network access. It lets a sleeping Mac wake for some requests on its local network. It is not a reliable way to wake a Mac over the internet, and Anywhere does not wake a sleeping Mac.

Restarts are the other trap. After a restart with FileVault on, a Mac waits at the unlock screen and no remote desktop app is running yet. If you have to restart it while you are away, sudo fdesetup authrestart restarts and unlocks it once.

So for a Mac you plan to reach remotely, keep it awake. For a desktop Mac with no monitor, see running a headless Mac mini.

Which method to use

One long job tonight

Run caffeinate -i in Terminal and press Control-C when it is done.

A MacBook that lives on its charger

Turn on the Battery option that prevents automatic sleeping on the power adapter.

A desktop Mac that is always on

Set it once in System Settings, under Energy.

A Mac you connect to remotely

Use Keep Active in Anywhere, with the pointer nudge if you don't want the lock screen to appear.

Good to know

How can I force my Mac to stay awake?

Run caffeinate -i in Terminal for a temporary hold, or change the sleep setting in System Settings: Battery > Options on a MacBook, Energy on a desktop Mac. The setting stays until you change it back.

How do I keep my Mac awake using Terminal?

Open Terminal and run caffeinate -i to prevent idle sleep, caffeinate -d to keep the display awake, or caffeinate -s to prevent sleep while on power. Press Control-C to stop.

Does caffeinate keep a Mac awake with the lid closed?

No. caffeinate does not keep a MacBook awake once the lid is closed. A MacBook stays awake with the lid closed only when it is on power with an external display attached.

How do I wake a Mac from sleep remotely?

You can't count on it. Wake for network access lets a sleeping Mac wake for some requests on its local network, but it is not a reliable way to wake a Mac over the internet. Keep the Mac awake instead.

Is there a free app that keeps a Mac awake?

Yes. Amphetamine is a free app on the Mac App Store that prevents a Mac from sleeping. If you want the Mac awake for remote access, Anywhere's Keep Active setting does that job.

Will my Mac lock while it is being kept awake?

It can, because staying awake and staying unlocked are separate things. A locked Mac is still reachable with Anywhere: you see the lock screen and type the password. Keep Active can also nudge the pointer so the lock screen doesn't appear.

Sources

Prices and features of other products were read from these pages on November 21, 2026 and may have changed since.

Take your Mac with you.

See and control your Mac from your phone, tablet or another computer. Install it on your Mac, Windows PC or Linux PC, sign in, and it's there whenever you need it.

iPhone and iPad

Almost on the App Store.

Anywhere for iPhone and iPad isn't out yet. Leave your email address and we'll tell you when it is.

We'll use it to tell you the app is out, and for nothing else. Privacy policy