How to configure Ollama port and networking
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
Stop the running Ollama service. Configuration changes require a service restart.
sudo systemctl stop ollamaExpected output: No error output; service stops cleanly.
Set the binding address and port via environment variable. The
OLLAMA_HOSTvariable controls the listen address. Use0.0.0.0to 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.
Persist the environment variable across reboots. On Linux, add the export line to a system-wide profile or systemd override.
sudo systemctl edit ollamaExpected output: An editor opens. Add the lines:
[Service] Environment="OLLAMA_HOST=0.0.0.0:11434"Save and exit.
Restart the Ollama service to apply the change.
sudo systemctl daemon-reload sudo systemctl restart ollamaExpected output: No error output; service transitions to active state.
Verify the service is listening on the configured address.
curl http://0.0.0.0:11434/api/versionExpected 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/tcpon 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.
ssornetstatshows port not open — Ollama may not have restarted successfully. Check logs withjournalctl -u ollama --no-pager -n 20.- Port 11434 already in use — Another process occupies the port. Identify the conflict with
lsof -i :11434or choose a different port by settingOLLAMA_HOST="0.0.0.0:11435".