> ## Content Index
> Fetch the complete content index at: https://locallabs-llm.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# Ollama keep_alive: retain or unload a model
- URL: https://locallabs-llm.org/ollama-keep-alive/
- Published: 2026-11-18T11:08:05.000Z
- Updated: 2026-11-27T09:55:54.000Z
- Description: Unload a model with ollama stop, set a server retention period and understand when a request overrides OLLAMA_KEEP_ALIVE.
- Author: Albert Curry
- Tags: Manage Ollama models

Use `ollama stop MODEL:TAG` to unload a model now. To change how long models remain loaded between requests, configure `OLLAMA_KEEP_ALIVE`; an API request's `keep_alive` value takes precedence. Unloading keeps the downloaded files.

## Release the running model

```
ollama ps
ollama stop llama3.2:3b
ollama ps
```

Replace the [example tag](https://ollama.com/library/llama3.2:3b?ref=locallabs-llm.org) with a name in your running list. The final check shows whether it has unloaded. The [Ollama memory-retention instructions](https://docs.ollama.com/faq?ref=locallabs-llm.org#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately) distinguish immediate unloading from the default five-minute retention period.

My default is to use `stop` when another application needs the memory. Removing the downloaded model is unnecessary for this task.

## Set a retention period for a manually started server

Stop the existing server before using either example below; don't start a second server on an occupied address. For a manual server on macOS or Linux, this shell command sets ten minutes:

![GNOME Console with OLLAMA_KEEP_ALIVE=10m ollama serve entered at the shell prompt.](https://storage.ghost.io/c/e0/70/e070c514-431e-4a20-aa04-a641625f58e7/content/images/2026/11/ollama-keep-alive-ui-v3.webp)

Linux terminal: Set a ten-minute retention period for a manually started server. [View larger](https://storage.ghost.io/c/e0/70/e070c514-431e-4a20-aa04-a641625f58e7/content/images/2026/11/ollama-keep-alive-ui-v3.webp?ref=locallabs-llm.org)

```
OLLAMA_KEEP_ALIVE=10m ollama serve
```

For a manually started server in PowerShell:

```
$env:OLLAMA_KEEP_ALIVE = '10m'
ollama serve
```

If you normally use the desktop app or a systemd service, follow the [platform-specific environment configuration](https://docs.ollama.com/faq?ref=locallabs-llm.org#how-do-i-configure-ollama-server) so the setting reaches that process, then restart it.

## Read a request's override correctly

Ollama accepts durations such as `10m`, a number of seconds, a negative value to keep a model loaded, or `0` to unload it after the request. The per-request `keep_alive` setting overrides the server default.

A negative duration disables the usual expiry, but it isn't a permanent memory reservation. Ollama can unload an idle model to make room for another model when memory is insufficient. Choose indefinite retention only when keeping that model ready is worth the memory cost; it doesn't make the answers more accurate.

Use [the running-model list](https://locallabs-llm.org/ollama-list-models/) to inspect the result. If your goal is disk space instead, use the [model removal command](https://locallabs-llm.org/ollama-delete-model/).