How to configure the Ollama serve port for network access
Ollama installed, command-line terminal access, basic networking knowledge
What this does
Rebinds the Ollama API server from localhost-only to a network-accessible address and port. After this guide remote clients will be able to reach the Ollama API over the network.
Steps
Set the OLLAMA_HOST environment variable and restart. Changes the bind address to accept external connections.
export OLLAMA_HOST=0.0.0.0:11434 ollama serveExpected output: Server starts, listening on all interfaces.
Configure the systemd service to persist the change. Adds the environment variable to the unit file.
sudo mkdir -p /etc/systemd/system/ollama.service.d sudo tee /etc/systemd/system/ollama.service.d/override.conf << 'EOF' [Service] Environment=OLLAMA_HOST=0.0.0.0:11434 EOF sudo systemctl daemon-reload && sudo systemctl restart ollamaOpen the firewall port. Allows inbound TCP traffic on the Ollama port.
sudo ufw allow 11434/tcp && sudo ufw reloadExpected output:
Rule addedandRules updated.Test remote access. Sends an API request from another machine to confirm the service is reachable.
curl http://<server-ip>:11434/api/tagsExpected output: A JSON array of available models.
Verification
curl -s http://localhost:11434/api/tags | python3 -m json.tool
# Expected: valid JSON with non-empty "models" array
Common failures
connection refused- Firewall blocking the port; verify withsudo ufw statusor check cloud security groups.address already in use- Another process is on port 11434; usesudo lsof -i :11434to identify it.OLLAMA_HOST not respected- The daemon may be started by systemd which ignores the shell export; always use the override.conf method for systemd setups.model unreachable after config- Client is using an IP that the server is not bound to; verify withss -tlnp | grep ollama.
Operator checkpoint
Before treating this as solved, write down the local runtime, model or package version, hardware/backend if relevant, and the verification output. This keeps the guide useful as a Will-It-Run style decision instead of a one-off command transcript.