Pair n8n with Ollama to run Llama-class models without per-token API bills. The key is correct Docker DNS—not localhost between containers.
Shared Compose networks let n8n call http://ollama:11434 by service name.
Compose network pattern
Put both services on one bridge network. Set n8n’s Ollama base URL to http://ollama:11434 (service name), then pull a model with docker exec + ollama run.
Keep heavy models on a GPU host; point n8n at Ollama over the private network.
Workflow tips
- Use HTTP Request nodes against Ollama’s API.
- Cap context size to protect RAM.
- For host-installed Ollama, see ECONNREFUSED fixes.