This guide shows how to configure Ollama to accept connections from any IP address instead of just localhost.
Check if Ollama is currently listening only on localhost:
ss -tulpn | grep 11434
If you see 127.0.0.1:11434
, it's only accessible locally.
# Stop Ollama service
sudo systemctl stop ollama
# Create override directory
sudo mkdir -p /etc/systemd/system/ollama.service.d
# Create override configuration
sudo nano /etc/systemd/system/ollama.service.d/override.conf
Add these lines to override.conf:
[Service]
Environment="OLLAMA_HOST=0.0.0.0"
# Reload systemd configuration
sudo systemctl daemon-reload
# Restart Ollama
sudo systemctl restart ollama
ss -tulpn | grep 11434
You should see *:11434
or 0.0.0.0:11434
, indicating it's listening on all interfaces.
Allow incoming traffic to port 11434:
sudo ufw allow 11434/tcp
- If using a cloud provider (AWS, DigitalOcean, etc.), ensure your security groups/network rules allow inbound traffic on port 11434
- Test the connection from another machine:
curl http://YOUR_SERVER_IP:11434/api/tags
- Consider implementing additional security measures like authentication or IP whitelisting for production use