A model server can serve local programs or clients on another network, depending on where it listens. The Ollama host address selects that interface and port, so a specific private address can make the API reachable from a private network.

For a Linux installation managed by systemd, OLLAMA_HOST belongs in the ollama service environment rather than a terminal's environment. You need sudo access, an installed ollama unit, and a stable private address assigned to the server.

Ollama's local API does not require authentication. Anyone who can reach its listening address can use it, so network access must already be limited to trusted clients before a non-loopback bind. A private IP address alone does not restrict which clients can connect.

Steps to set the Ollama host address:

  1. Identify the server's private IPv4 address.
    $ ip -4 -brief address show

    The address 192.0.2.10 below represents the server's private interface; replace it with an address assigned to your server. 127.0.0.1:11434 is Ollama's default for local-only access. 0.0.0.0 would listen on every IPv4 interface, including any public interface.

  2. Inspect the Ollama unit and its existing overrides.
    $ sudo systemctl cat ollama.service

    A later drop-in can override an earlier OLLAMA_HOST value. An existing host setting needs updating in its owning file rather than a conflicting second definition. The dedicated host.conf below must be new; replacing an existing file would discard its contents.

  3. Create the Ollama service's drop-in directory.
    $ sudo install -d -m 0755 /etc/systemd/system/ollama.service.d
  4. Set the private listen address in the new host.conf drop-in.
    $ sudo tee /etc/systemd/system/ollama.service.d/host.conf <<'EOF'
    [Service]
    Environment="OLLAMA_HOST=192.0.2.10:11434"
    EOF
    [Service]
    Environment="OLLAMA_HOST=192.0.2.10:11434"

    The output is tee echoing the saved configuration. A different port belongs after the colon. To recover from an unwanted bind change when host.conf contains only this setting, sudo rm /etc/systemd/system/ollama.service.d/host.conf removes this drop-in; repeating the reload and restart restores the previous service configuration.

  5. Reload systemd's unit definitions.
    $ sudo systemctl daemon-reload
  6. Restart the Ollama service to apply the address.

    A restart interrupts active requests and unloads models. Binding only the private address also stops local clients from reaching Ollama through 127.0.0.1; those clients need the new server URL.

    $ sudo systemctl restart ollama
  7. Confirm that the listener uses the chosen local address.
    $ ss -ltn 'sport = :11434'
    State  Recv-Q Send-Q Local Address:Port  Peer Address:Port
    LISTEN 0      4096      192.0.2.10:11434      0.0.0.0:*

    The Local Address column must contain the chosen interface and port. 0.0.0.0:* in the Peer Address column does not mean the server listens on all interfaces. No listener after startup, or a different local address, calls for service-log inspection.
    Related: How to view Ollama logs

  8. Check that the old loopback endpoint refuses connections on the server.
    $ curl -fsS --connect-timeout 3 http://127.0.0.1:11434/api/version
    curl: (7) Failed to connect to 127.0.0.1 port 11434 after 0 ms: Could not connect to server

    Connection refusal is expected after binding only the private address. An answering loopback endpoint can indicate another Ollama process or an unapplied setting.

  9. Request the API from a trusted client on the private network.
    $ curl -fsS --connect-timeout 3 http://192.0.2.10:11434/api/version
    {"version":"0.40.12"}

    The returned version depends on the installed release. An HTTP response from the client confirms access through the chosen address; a timeout can indicate routing or firewall restrictions even when the server has a listener.

Share this guide