#!/bin/bash # Run this ON THE GPU VM (10.0.30.63) to fix Ollama remote access echo "=== Fixing Ollama Remote Access ===" echo "" # Check if Ollama is running if ! systemctl is-active --quiet ollama; then echo "✗ Ollama is not running. Starting it..." sudo systemctl start ollama sleep 2 fi echo "✓ Ollama is running" echo "" # Check what it's listening on echo "Current Ollama listening status:" sudo netstat -tlnp 2>/dev/null | grep 11434 || ss -tlnp 2>/dev/null | grep 11434 echo "" # Create systemd override echo "Creating systemd override to listen on all interfaces..." sudo mkdir -p /etc/systemd/system/ollama.service.d sudo tee /etc/systemd/system/ollama.service.d/override.conf > /dev/null <<'EOF' [Service] Environment="OLLAMA_HOST=0.0.0.0:11434" EOF echo "✓ Override file created" echo "" # Reload and restart echo "Reloading systemd and restarting Ollama..." sudo systemctl daemon-reload sudo systemctl restart ollama sleep 3 echo "✓ Ollama restarted" echo "" # Verify echo "Verifying configuration..." if sudo netstat -tlnp 2>/dev/null | grep -q "0.0.0.0:11434" || sudo ss -tlnp 2>/dev/null | grep -q "0.0.0.0:11434"; then echo "✓ SUCCESS! Ollama is now listening on 0.0.0.0:11434" echo "" echo "Test from your local machine:" echo " curl http://10.0.30.63:11434/api/tags" else echo "✗ Still not listening on 0.0.0.0 - checking status..." sudo systemctl status ollama --no-pager | head -10 echo "" echo "Try checking Ollama logs:" echo " sudo journalctl -u ollama -n 20" fi