How to Use n8n with Local LLM Ollama: Complete Setup Guide

Connecting n8n to Ollama gives you a fully local, private AI automation stack — n8n orchestrates the workflows and Ollama handles inference, with no data leaving your machine or server. The combination is particularly popular for teams that want automation capabilities similar to cloud services like Zapier with OpenAI, but with complete data privacy and no API costs. This guide covers the complete setup, networking configuration for Docker deployments, and building practical workflows with the local LLM backend.

What the Integration Provides

n8n has native Ollama support through two dedicated nodes: Ollama Chat Model and Ollama Model. The Ollama Chat Model node is the primary one for AI Agent and LLM Chain workflows — it connects to your Ollama instance, lists available models, and handles the chat message format. The Ollama Model node is for embedding workflows using Ollama’s embedding endpoint. Both nodes point to your Ollama instance’s API URL, with no API key required since Ollama runs locally without authentication. Once connected, any workflow that uses an AI Agent, LLM Chain, or other AI node can use your local model as the backend.

Installation: Docker Compose Setup

The recommended setup for n8n with Ollama is Docker Compose, which manages both services together. Create a docker-compose.yml that defines two services: n8n (using the official n8n Docker image, exposing port 5678, with a volume for persistent data) and Ollama (using the ollama/ollama image, with a volume for model storage and GPU passthrough if applicable). Place both services on the same Docker network so they can communicate by service name. In this configuration, n8n reaches Ollama at http://ollama:11434 — using the service name rather than localhost, because within Docker each container has its own localhost. Set OLLAMA_HOST to 0.0.0.0 in the Ollama service environment so it accepts connections from other containers on the network.

Figure 1 — n8n + Ollama: network architecture

n8n :5678 workflow engine Ollama :11434 LLM inference Docker network http://ollama:11434

Connecting Ollama in n8n Settings

In n8n’s workflow editor, add an Ollama Chat Model node (found under AI > Language Models). Click the Credential field and create a new Ollama API credential. Set the Base URL to your Ollama instance — http://ollama:11434 if running in Docker Compose with the service named “ollama”, or http://localhost:11434 if n8n and Ollama are both running natively on the same machine, or http://YOUR_MACHINE_IP:11434 if Ollama is on a different machine. Save the credential. Back in the node, select your model from the dropdown — n8n queries Ollama’s /api/tags endpoint to list available models. Pull a model first in Ollama if the list is empty.

Your First n8n + Ollama Workflow

The simplest working workflow: a Chat Trigger node → AI Agent node → Ollama Chat Model node. Add the Chat Trigger, connect it to an AI Agent, then connect an Ollama Chat Model node to the AI Agent’s Chat Model input. Configure the Ollama node with your credential and select a model. Click Execute Workflow, then open the chat panel that appears in the Chat Trigger node. Send a message — it routes through n8n to Ollama and the response streams back. This confirms the end-to-end connection before adding complexity. From here, connect tools (Calculator, HTTP Request for external APIs, database nodes) to the AI Agent’s Tools input to extend its capabilities.

Model Recommendations for n8n Workflows

Not all Ollama models perform equally well in n8n’s tool-calling workflows. Qwen2.5-7B is the recommended starting point — it has strong tool calling support, fits in 6–8GB RAM in Q4, and produces consistent JSON output for tool invocations. Llama 3.2 3B is a good option when RAM is constrained — smaller but still functional for tool calling. Phi-4-mini (3.8B) is a strong alternative with better reasoning per parameter than most 3B models. Avoid models under 1.5B for tool calling — they struggle to produce reliable JSON tool call format. For LLM Chain workflows (no tool calling, just text generation or extraction), smaller models work well and response quality scales more linearly with size.

Handling the Docker Networking Common Mistake

The most common setup error: n8n runs in Docker but tries to connect to Ollama at localhost:11434, which resolves to the n8n container’s own localhost — not the host machine where Ollama is running. The fix depends on your setup. If both run in Docker Compose on the same network, use the Ollama service name: http://ollama:11434. If n8n runs in Docker but Ollama runs natively on the host machine (Linux), use the Docker bridge gateway IP: http://172.17.0.1:11434. On Mac or Windows with Docker Desktop, use http://host.docker.internal:11434. If you see “connection refused” errors in n8n when testing the Ollama credential, this networking misconfiguration is almost certainly the cause.

Frequently Asked Questions

Can n8n pull Ollama models automatically?
Not natively — you need to pull models in Ollama before they appear in n8n’s model dropdown. Add an HTTP Request node in a utility workflow that calls Ollama’s /api/pull endpoint to automate model pulling from within n8n if needed.
Does n8n Cloud work with local Ollama?
Not directly — n8n Cloud runs on n8n’s servers and cannot reach localhost on your machine. To use Ollama with n8n Cloud, expose your Ollama instance to the internet (with authentication) via a reverse proxy, or use n8n’s self-hosted version which runs on your own infrastructure alongside Ollama.
How do I update models in Ollama from n8n?
Use an HTTP Request node pointing at Ollama’s REST API (POST to /api/pull with the model name in the request body). Trigger it from a Schedule node for automatic updates or from a manual trigger when you want to refresh a model.

Last updated: October 2026

Building a RAG Workflow with n8n and Ollama

One of the most practical n8n + Ollama workflows is retrieval-augmented generation over your own documents. The setup: a vector store node (Qdrant, Chroma, or Supabase pgvector all have n8n nodes) stores embeddings of your documents generated by Ollama’s embedding model. When a user sends a query through the Chat Trigger, an Ollama Embeddings node converts the query to a vector, the vector store retrieves the most relevant document chunks, and the AI Agent node receives both the query and the retrieved context before generating a response. This keeps the entire pipeline local — embeddings generated locally, vector store self-hosted, inference via Ollama — with no document content leaving your infrastructure. The n8n self-hosted AI starter kit (available in n8n’s GitHub repository) provides a pre-built Docker Compose configuration that includes n8n, Ollama, Qdrant, and Open WebUI as a starting point for this architecture.

Monitoring and Logging n8n + Ollama Workflows

For production n8n + Ollama deployments, monitoring execution health is important. n8n’s execution log (available in the Executions panel) records every workflow run, showing success/failure status, execution time, and error messages. For more detailed monitoring, use n8n’s log streaming feature to forward execution logs to an external logging service or to Loki for Grafana dashboards. Monitor Ollama’s inference latency via its Prometheus metrics endpoint alongside n8n execution time to identify whether slow workflows are waiting on LLM inference or on other operations. Set up email or Slack notifications in n8n for workflow failures using the Error Trigger node so you are alerted when something breaks in production without having to check the execution log manually.

The n8n + Ollama combination represents the current state of the art for self-hosted AI automation: the full power of a workflow automation platform with LLM reasoning, connected to local inference that costs nothing per call and sends no data externally. The initial Docker Compose setup takes under an hour, and from there the workflow library grows incrementally as you identify automation opportunities. Start with the simplest possible chat workflow, verify the Ollama connection, then add one real tool — a database query, an email integration, a web search — before building more complex agent workflows.

Securing Your n8n and Ollama Stack

A local AI stack is private by default, but only if you keep it that way. Ollama has no built-in authentication, so never publish port 11434 to the internet. In a Docker Compose setup, leave the port unpublished and let n8n reach Ollama over the internal network by service name. If you need access from other machines, put a reverse proxy such as Caddy or Nginx in front with HTTPS and an access control layer, and restrict it to known IP ranges.

For n8n itself, create the owner account on first launch, use a strong password, and set the N8N_ENCRYPTION_KEY environment variable to a stable value so stored credentials remain readable after you rebuild the container. Back up the data volume regularly, because your workflows and credentials live there. Treat webhook URLs as secrets, since anyone who knows a production webhook address can trigger the workflow. Finally, keep both images updated on a schedule, pin versions rather than using the latest tag, and read release notes before upgrading, as node behaviour occasionally changes between versions. A few minutes of hardening up front keeps a convenient home automation setup from becoming an accidental open door.

Leave a Comment