everyday mac tools

Stop a Mac sleeping during a long download or upload

· 6 min read

A Mac that goes to sleep in the middle of a large download or upload will usually pause it, and some transfers do not resume cleanly afterward. The reliable fix is to keep the Mac awake for exactly as long as the transfer runs, using either a setting in System Settings or the caffeinate command in Terminal, then let normal sleep come back on its own.

Leaving sleep switched off permanently works too, but it costs battery and heat for no benefit the rest of the time. The approaches below are ordered from simplest to most precise.

Why the Mac sleeps even though something is running

macOS decides whether to sleep based on idle time: no keyboard or trackpad input for the period you set. Apps can tell the system “I am busy, do not sleep”, which is called a power assertion. Some download and backup tools do this while they work; plenty do not, and a browser tab uploading a file to a website may not.

You can see who is currently holding the Mac awake. Open Terminal and run:

pmset -g assertions

Look for lines mentioning PreventUserIdleSystemSleep. If the app doing your transfer is not listed, nothing is stopping the Mac from sleeping when the idle timer runs out.

Two things always win regardless: closing a MacBook’s lid sleeps it (unless it is set up with an external display, power and a keyboard), and a battery running out ends everything. Plug in before starting anything long.

The quick setting for a plugged-in MacBook

On a MacBook, the setting that matters is in System Settings, Battery, then Options (the button name varies slightly between macOS versions).

  1. Turn on Prevent automatic sleeping on power adapter when the display is off.
  2. Keep the Mac connected to power for the whole transfer.

The display can then turn off to save the screen while the Mac itself keeps working. On a Mac mini, iMac or Mac Studio, the equivalent option lives in System Settings, Energy.

The display timing itself is set in System Settings, Lock Screen, under the options to turn the display off when inactive. You do not need to change those for the transfer to continue; the setting above is what keeps the system awake.

The drawback is that you have to remember to turn it back off, and most people do not.

Keep it awake for one job with caffeinate

caffeinate is built into macOS and is the tidier answer, because it stops the moment you stop it.

Awake until you press Control-C:

caffeinate -i

Leave the Terminal window open. The -i flag prevents idle sleep. Add -d if you also want the display to stay on, which is handy when you want to glance at a progress bar.

Awake for a set time:

caffeinate -i -t 7200

The number is seconds, so this is two hours. When it expires, the Mac goes back to its usual behavior with nothing to undo.

Awake until a specific app finishes. This is the most precise version. Find the process ID of the app doing the transfer in Activity Monitor (the PID column), then run:

caffeinate -i -w 12345

with your PID in place of 12345. When that process quits, caffeinate exits and sleep is allowed again. It suits a command-line download or a tool that closes itself when done.

Wrap a Terminal command. If the transfer is itself a Terminal command, put caffeinate -i in front of it and the Mac stays awake for exactly that command’s lifetime.

If you do this every week

Retyping a command is fine once. If large transfers are routine (a nightly upload, footage offloaded from a camera, a game library), a repeatable switch is easier.

Mainspring has a caffeinate-on-a-timer power-up, which keeps the Mac awake for a period you choose and lets it sleep normally afterward, from the menu bar. Every power-up is snapshotted before it changes, so it flips back in one click. It also offers a never-sleep-with-lid-closed power-up for the rarer case where a MacBook has to keep working shut, and scenes can switch on automatically on triggers such as an app opening, which suits a transfer app you only launch for this job. It is a paid app with a free one-day trial; everything here can also be done by hand with the steps above.

What sleep does to a transfer, and how to check

If the Mac did sleep, find out what actually happened before starting again.

  • Browser downloads usually pause and may offer a resume option in the downloads list. If the server does not support resuming, the download restarts from zero or fails, and the partial file is useless. A zip that was cut off this way often gives the error covered in the Mac says it is unable to expand a zip file.
  • Cloud sync and backup tools generally pick up where they left off, because they track which files are done.
  • Uploads through a web page are the most fragile. If the tab has to start over, keep the Mac awake from the very beginning next time.

Always compare the finished file size with the source before deleting the original or closing the job.

When keeping the Mac awake is the wrong answer

Some situations call for a different approach.

  • On battery. Keeping a MacBook awake drains it, and a dead battery stops the transfer anyway. Plug in.
  • In a bag. A MacBook forced to stay awake with the lid closed inside a bag can get hot. Keeping a MacBook awake with the lid closed covers when that is sensible and when it is not.
  • On an unreliable connection. If transfers fail regardless of sleep, the network is the real issue, and staying awake only means it fails with the screen on.

Questions

Does Power Nap keep downloads going while the Mac sleeps? Power Nap lets certain Apple services check for updates during sleep. It is not a general way to keep third-party downloads or browser uploads running, so do not rely on it for a large transfer.

Will caffeinate keep working if I close the Terminal window? Closing the window ends the command, and normal sleep returns. Leave the window open, or use the timed version so you do not have to think about it.

Is it bad for a Mac to stay awake overnight? Not if it is on power, has airflow and is not in a bag. It simply uses more electricity than sleeping would. Letting it return to normal sleep afterward is the better habit.