HOW-TO · SET

How to configure Ollama port and networking

intermediate10 minBy Fredoline Eruo
Target environment
Ubuntu 24.04 · Ollama 0.4.xWindows 11 · Ollama 0.4.xmacOS 15 · Ollama 0.4.x
PREREQUISITES

Ollama installed, terminal access, and basic familiarity with environment variable configuration.

What this does

This guide configures the TCP port on which Ollama listens and enables remote API access across a LAN. By default Ollama binds to 127.0.0.1:11434. Changing this allows clients on other machines to send inference requests to the host.

Steps

  1. Stop the running Ollama service. Configuration changes require a service restart.

    sudo systemctl stop ollama
    

    Expected output: No error output; service stops cleanly.

  2. Set the binding address and port via environment variable. The OLLAMA_HOST variable controls the listen address. Use 0.0.0.0 to accept connections from any network interface.

    export OLLAMA_HOST="0.0.0.0:11434"
    

    Expected output: No output; the variable is set in the current shell.

  3. Persist the environment variable across reboots. On Linux, add the export line to a system-wide profile or systemd override.

    sudo systemctl edit ollama
    

    Expected output: An editor opens. Add the lines:

    [Service]
    Environment="OLLAMA_HOST=0.0.0.0:11434"
    

    Save and exit.

  4. Restart the Ollama service to apply the change.

    sudo systemctl daemon-reload
    sudo systemctl restart ollama
    

    Expected output: No error output; service transitions to active state.

  5. Verify the service is listening on the configured address.

    curl http://0.0.0.0:11434/api/version
    

    Expected output: {"version":"0.4.x"}

Verification

ss -tlnp | grep 11434
# Expected: LISTEN entries showing 0.0.0.0:11434 or :::11434

Common failures

  • Service refuses connections after restart — Firewall blocking the port. Run sudo ufw allow 11434/tcp on systems using UFW.
  • Still binding to 127.0.0.1 after restart — Environment variable not loaded correctly. Verify the systemd override with systemctl show ollama --property Environment.
  • Remote client times out — Host firewall or router firewall blocking the port. Check both local and network-level rules.
  • ss or netstat shows port not open — Ollama may not have restarted successfully. Check logs with journalctl -u ollama --no-pager -n 20.
  • Port 11434 already in use — Another process occupies the port. Identify the conflict with lsof -i :11434 or choose a different port by setting OLLAMA_HOST="0.0.0.0:11435".

Related guides

RELATED GUIDES