Configuring the Ollama server

Ollama · Advanced · 12 min

Real setups need models on a bigger disk, remote access or tuned limits, all controlled by server settings.

The Ollama server reads its settings from environment variables (named values the operating system passes to programs). ollama serve --help lists them. Common ones:

  • OLLAMA_HOST: the address and port to listen on. Default 127.0.0.1:11434, which only accepts connections from the same computer.
  • OLLAMA_MODELS: the folder where models are stored, for example a larger disk.
  • OLLAMA_KEEP_ALIVE, OLLAMA_CONTEXT_LENGTH, OLLAMA_NUM_PARALLEL: defaults covered in other lessons.
  • OLLAMA_ORIGINS: extra web origins (sites or browser extensions) allowed to call the API from a browser.
  • OLLAMA_DEBUG=1: more detailed logs.
  • OLLAMA_NO_CLOUD=1: turn off cloud features.

Setting them depends on the system:

  • macOS (app): launchctl setenv OLLAMA_MODELS /Volumes/Big/models for each variable, then quit and restart the Ollama app.
  • Linux (systemd service): run sudo systemctl edit ollama.service, add lines like Environment="OLLAMA_MODELS=/data/ollama" under [Service], then sudo systemctl daemon-reload and sudo systemctl restart ollama. The ollama system user needs read and write access to a new models folder.
  • Windows: quit Ollama, add the variables in your account's environment variables settings, then start Ollama again.

Setting a variable in your own terminal doesn't affect a server that the app or service already started; this is the most common confusion.

Logs: on Linux, journalctl -e -u ollama. On macOS, ~/.ollama/logs/server.log. On Windows, the logs folder under %LOCALAPPDATA%\Ollama. Logs show GPU detection, memory estimates and load errors.

Proxies: if downloads must go through a company proxy, set HTTPS_PROXY for the server.

Example

# Linux (systemd): move models and allow network access
sudo systemctl edit ollama.service
#   [Service]
#   Environment="OLLAMA_MODELS=/data/ollama/models"
#   Environment="OLLAMA_HOST=0.0.0.0:11434"
sudo mkdir -p /data/ollama/models && sudo chown -R ollama:ollama /data/ollama
sudo systemctl daemon-reload && sudo systemctl restart ollama
journalctl -e -u ollama            # check startup, GPU detection, errors

# macOS (app): set, then restart the Ollama app
launchctl setenv OLLAMA_MODELS "/Volumes/Big/ollama-models"

# Any OS: list supported variables
ollama serve --help

Remember

  • Server settings are environment variables (ollama serve --help)
  • Set them via launchctl (macOS), systemd override (Linux) or system settings (Windows), then restart
  • Logs: journalctl on Linux, ~/.ollama/logs on macOS

Watch out for

  • Exporting a variable in a terminal and expecting the already-running app or service to pick it up.

Check yourself

  1. On Linux you set OLLAMA_MODELS in your shell profile, but the service still uses the old folder. Why?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.ollama.com/faq