How to Prevent Your Mac from Sleeping While Downloading Large Files

Downloading a massive file, such as a 50GB video game, a 4K movie edit, or a major operating system update, can take hours depending on your internet connection. Naturally, you might want to walk away from your Mac while it works. However, macOS is designed to conserve energy aggressively. By default, if you do not touch the mouse or keyboard for a set period, your Mac will go to sleep, instantly cutting off the Wi-Fi connection and causing your download to fail or pause indefinitely.

To ensure your downloads finish successfully while you are away, you must temporarily prevent your Mac from entering sleep mode. While you could delve into the System Settings and alter your permanent power profiles, there is a much faster, temporary solution built directly into macOS.

Using the Terminal “Caffeinate” Command

macOS includes a hidden, built-in command-line utility called caffeinate. As the name suggests, it acts like a cup of coffee for your Mac, keeping it wide awake for as long as the command is running, without forcing you to change your global energy settings.

  1. Open the Terminal application on your Mac. You can find it by pressing Command + Space to open Spotlight Search, typing “Terminal”, and pressing Enter.
  2. In the Terminal window, type the following word:
    caffeinate
  3. Press the Enter (Return) key.

That is all it takes. The cursor will move to the next line, but no text will appear. As long as this Terminal window remains open and the caffeinate command is running, your Mac will never go to sleep, ensuring your massive downloads finish uninterrupted. (Note: Your screen may still dim or turn off to save power, but the computer itself and the internet connection will remain fully active).

Stopping the Command

Once your download is completely finished, you should allow your Mac to return to its normal energy-saving behaviour.

  1. Click back into the Terminal window where caffeinate is running.
  2. Press Control + C on your keyboard.
  3. This immediately terminates the command. You will see a new prompt line appear, indicating the terminal is ready for a new instruction.
  4. You can now safely close the Terminal window, and your Mac will resume its normal sleep schedule.

Caffeinate with a Time Limit

If you know a download will take exactly two hours, and you want the Mac to sleep automatically afterwards so it isn’t running all night, you can add a specific time limit (in seconds) to the command.

  1. Open Terminal.
  2. Type caffeinate -t followed by a space, and then the number of seconds. For example, to keep the Mac awake for two hours (7200 seconds), you would type:
    caffeinate -t 7200
  3. Press Enter. The Mac will stay awake for exactly two hours, after which the command will end automatically, and the computer will be allowed to sleep.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.