For agents · Ollama

Keep your Mac awake
while Ollama works.

Ollama serves models from your own Mac, so when the Mac sleeps, every agent and app calling it gets an error. Midnight Oil keeps the Mac awake while Ollama is running, or just for a long download.

The short answer

Add an App Running trigger for Ollama in Midnight Oil and the Mac stays awake whenever Ollama is running. Running the server by hand? midnightoil run -- ollama serve. Pulling a big model? midnightoil run -- ollama pull <model>.

Ollama at a glance

Runs whereOn your Mac, as the Ollama app or ollama serve
ServesA local API on port 11434 that agents and apps call
Long jobsModel downloads, batch generation, agents using a local model
Instructions fileNone; the agents that call it have their own
Needs your Mac awake?Yes, for as long as anything is calling it

What happens when your Mac sleeps mid-run

When the Mac sleeps, the Ollama server freezes. Requests in progress fail, and agents calling it, like Aider or Cline pointed at a local model, see connection errors and stop. A model download pauses partway too.

OLLAMA_KEEP_ALIVE doesn't help here: it controls how long a model stays loaded in memory, not whether the Mac stays awake.

Running Ollama unattended

Using the Ollama app: Midnight Oil's Settings › Triggers › Add Trigger › App Running › Ollama keeps the Mac awake whenever Ollama is running and lets it sleep once you quit it.

Running the server yourself: midnightoil run -- ollama serve keeps the Mac awake for exactly as long as the server runs.

Big downloads: wrap ollama pull and the session ends the moment the model is on disk. Turn on --allow-display-sleep so the screen goes dark while the Mac keeps working.

Keep the Mac awake for the whole session

midnightoil run -- ollama serve

Or for one unattended run

midnightoil run -- ollama pull llama3.3

Lid closed, battery safe

Add --lid-closed and Ollama keeps working with the laptop shut. It needs a one-time approval in Midnight Oil's Settings › Closed Lid, and normal sleep comes back the moment the session ends, even if the app quits or crashes.

On battery, sessions can end when you unplug or drop below a level you pick, and an alarm sounds if the lid closes during a closed-lid session. Add --allow-display-sleep to let the screen go dark while the Mac keeps working. The full setup is in how to run AI agents overnight.

Questions

Does Ollama keep running when my Mac sleeps?

No. The server pauses with the Mac, so requests fail and agents using a local model stop. Keep the Mac awake while Ollama runs with an App Running trigger in Midnight Oil.

Does OLLAMA_KEEP_ALIVE keep my Mac awake?

No. It sets how long Ollama keeps a model loaded in memory after a request. It has no effect on Mac sleep.

Can I use my Mac as an always-on Ollama server?

Yes, for as long as you want. Run midnightoil run -- ollama serve, or a trigger for the Ollama app, and set sessions to end on battery if it's a laptop.

Let Ollama work the night shift.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/midnightoil