How to Connect Ollama to n8n for Local AI Workflows

n8n is an open-source workflow automation tool — think Zapier or Make, but self-hosted, and with first-class support for AI nodes that can call local LLMs. Connecting it to Ollama gives you a powerful combination: visual workflow automation with local AI processing, running entirely on your own infrastructure. You can build pipelines that classify emails, summarise documents, generate content, answer questions from a knowledge base, and dozens of other AI tasks — all without sending data to external APIs or paying per token.

What You Can Build with n8n + Ollama

Before getting into setup, it’s worth grounding what this combination is actually good for. A few practical workflow examples that work well:

Email triage and classification. Connect your email inbox via IMAP, pass each incoming email to Ollama for classification (urgent/not urgent, category, required action), and route to different folders or trigger follow-up actions based on the output. Runs entirely locally, processes emails in seconds, no email content sent to cloud APIs.

Document summarisation pipeline. Watch a folder for new PDF or document uploads, extract text, summarise with Ollama, and post the summary to Slack or save to a database. Useful for teams that receive a high volume of reports or papers.

Local RAG over your knowledge base. Index a set of documents (using n8n’s HTTP nodes to call Ollama’s embeddings API), store embeddings in a vector database, and build a query workflow that retrieves relevant chunks and generates answers. A private, self-hosted Q&A system over your team’s internal knowledge.

Content generation batch jobs. Feed a list of topics or data from a spreadsheet, generate content for each with Ollama, and write outputs to a Google Sheet or database. Useful for generating product descriptions, FAQ entries, or documentation drafts at scale.

Installing n8n

n8n runs as a Node.js application and is easiest to set up with Docker:

docker run -it --rm   --name n8n   -p 5678:5678   -v ~/.n8n:/home/node/.n8n   docker.n8n.io/n8nio/n8n

Open http://localhost:5678 in your browser. Create an account (it’s local — just a username and password for the local UI) and you’ll see the workflow editor.

For a persistent installation that survives container restarts:

version: '3.8'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=yourpassword
volumes:
  n8n_data:

Save as docker-compose.yml and run with docker compose up -d.

Connecting n8n to Ollama

n8n has a built-in Ollama node in its AI section. In the workflow editor, add a new node and search for “Ollama”. You’ll find:

  • Ollama Chat Model — for conversational LLM calls
  • Ollama Embeddings — for generating text embeddings

When you add an Ollama Chat Model node, it asks for credentials. Create a new Ollama credential and set the Base URL to http://localhost:11434 (or http://host.docker.internal:11434 if n8n is in Docker and Ollama is on the host machine — Docker containers can’t use “localhost” to reach the host).

The Ollama node connects to your running Ollama instance. Select the model from the dropdown (it pulls the list from Ollama’s tags API automatically) and you’re ready to build.

Figure 1 — n8n + Ollama: Example Workflow Architecture

Trigger Webhook / cron IMAP / file watch Prepare Input Extract text Build prompt Ollama Node Chat / Generate Local model no data leaves machine Process Output Parse / route Store / notify n8n handles orchestration — Ollama handles inference

Building Your First AI Workflow

Let’s build a simple document summarisation workflow to understand the pattern. In the n8n editor:

  1. Add a Manual Trigger node (for testing — you’ll replace this with a real trigger later)
  2. Add an HTTP Request node to fetch or read your document content
  3. Add a Basic LLM Chain node from the AI section — this is n8n’s wrapper for LLM calls
  4. In the Basic LLM Chain node, click “Chat Model” and add an Ollama Chat Model sub-node
  5. Configure the Ollama credentials (Base URL: http://localhost:11434) and select your model
  6. Set your prompt in the LLM Chain: Summarise the following document in 3 bullet points: {{ $json.text }}
  7. Add a final node to save or send the output (Google Sheets, Slack, email, database)

Execute the workflow with the test button. If everything is configured correctly, you’ll see the Ollama node call your local model and return the summary. The {{ $json.text }} syntax is n8n’s expression language — it references the text field from the previous node’s output. Adjust this to match whatever field your document content is in.

The AI Agent Node

n8n’s most powerful AI feature is the AI Agent node, which gives your workflow a ReAct-style agent backed by your Ollama model. The agent can use tools — other n8n nodes — to take actions like searching the web, querying a database, calling an API, or running a calculation, and reason about which tool to use based on the user’s input.

To set up an agent: add an AI Agent node, connect an Ollama Chat Model as the brain, and add tool nodes as sub-nodes. Built-in tools include web search (via SerpAPI), calculator, Wikipedia, and custom HTTP requests. You can also connect any n8n node as a custom tool by wrapping it in a Tool node.

A practical example: a research assistant agent that can search the web, summarise pages, and answer questions about the results — all triggered by a webhook so you can query it from anywhere. The Ollama model handles the reasoning about which tools to use and how to synthesise the results; n8n handles the tool execution and orchestration.

Handling the Docker Networking Challenge

The most common stumbling block when running n8n in Docker alongside Ollama on the host machine is networking. When n8n is in Docker and Ollama is running natively on the host, localhost from inside the container refers to the container itself, not the host machine. Use host.docker.internal instead:

  • macOS / Windows Docker Desktop: http://host.docker.internal:11434 — works automatically
  • Linux: http://172.17.0.1:11434 (default Docker bridge gateway) or add --add-host=host.docker.internal:host-gateway to your docker run command

Also make sure Ollama is configured to accept connections from the Docker network: set OLLAMA_HOST=0.0.0.0:11434 so it listens on all interfaces including the Docker bridge. If both n8n and Ollama are in Docker (using docker-compose), you can connect them on the same Docker network and use the service name as the hostname — much cleaner than the host networking approach.

Figure 2 — Practical n8n + Ollama Use Cases

Workflow Trigger Ollama Task Email triageNew email arrives (IMAP)Classify + extract action items Doc summariserFile added to watched folderSummarise + post to Slack Content generatorNew row in Google SheetsGenerate description / copy Support botWebhook from chat widgetRAG answer from docs Data enrichmentScheduled batch jobExtract structured data from text

Performance Considerations

n8n workflows that call Ollama run as fast as your model generates — which means a 7B model producing a 300-token summary takes roughly 3–10 seconds depending on hardware. For individual triggered workflows this is fine. For batch jobs processing hundreds of items, the serial nature of Ollama’s default single-worker mode means total runtime scales linearly. A 500-document batch with a 5-second average inference time takes roughly 40 minutes end-to-end. For faster batch processing, set OLLAMA_NUM_PARALLEL=2 or higher and configure n8n to run parallel executions — n8n’s execution settings allow multiple workflow instances to run simultaneously, which combined with Ollama’s parallel workers gives you real concurrency. Just make sure your hardware has the RAM headroom for multiple concurrent model instances before enabling this.

Keeping Workflows Maintainable

A few practices make n8n AI workflows easier to maintain over time. Store your prompts as n8n expressions or environment variables rather than hardcoding them in nodes — this makes prompt updates without workflow edits much easier. Use n8n’s built-in error handling nodes to catch failures from the Ollama API (timeouts, model not found, OOM errors) and route them to appropriate error handling rather than silently failing. Test workflows with small batches before running on full datasets — a prompt that works on 10 documents sometimes fails on document 47 due to unusual content. And document what each workflow does in n8n’s workflow notes feature — the visual graph makes it easy to understand structure but not always intent, especially for complex multi-step AI workflows. n8n with Ollama is a genuinely powerful combination for building private, self-hosted AI automation — the visual workflow builder lowers the barrier to building complex pipelines, and the local Ollama backend means sensitive data stays on your infrastructure throughout.

n8n vs Make and Zapier for Local AI Workflows

If you’re evaluating n8n against cloud automation tools like Make or Zapier for AI workflows, the comparison comes down to one central question: do you need your data to stay local? Make and Zapier both support calling external AI APIs, and they’re more polished, have better third-party integrations, and have lower setup friction. But every document, email, and data point you process through them passes through external servers. For workflows involving sensitive business data, personal information, confidential communications, or proprietary content, this is a meaningful concern. n8n self-hosted with Ollama keeps everything on your infrastructure — the workflow orchestration, the AI inference, and the data all run on machines you control. The setup cost is higher: you need Docker running, you need to manage n8n and Ollama yourself, and the initial configuration is more involved than signing up for a SaaS tool. But the payoff is a private, infinitely scalable (within your hardware limits), zero-marginal-cost AI automation stack. For individuals and teams that handle sensitive data or have strong privacy requirements, that tradeoff is compelling. For workflows that process non-sensitive data and benefit from Make or Zapier’s polished integrations with hundreds of cloud services, the hosted tools are often the better practical choice. The honest recommendation: use cloud automation tools for workflows where data sensitivity isn’t a concern and integration breadth matters, use n8n + Ollama for workflows where data privacy is paramount or where the per-API-call costs of cloud LLMs would be prohibitive at your processing volume.

Getting Started: Your First Workflow in 15 Minutes

The fastest path to a working n8n + Ollama workflow: start Docker, run the n8n container with the command above, open the UI at localhost:5678, and build the simplest possible workflow — a Manual Trigger node connected to a Basic LLM Chain node connected to a Set node that stores the output. This three-node workflow validates that your Ollama connection is working and gives you a foundation to build on. Once that works, add complexity incrementally: a real trigger (webhook or scheduled), an input processing step, and a real output destination. Every working workflow you build gives you a reusable pattern for the next one, and n8n’s template library has dozens of AI workflow examples to adapt. The combination of local AI and visual automation is genuinely useful once it’s running — the investment in getting it set up pays off quickly for anyone doing repetitive text processing or content generation work.

Connecting n8n to Ollama’s OpenAI-Compatible Endpoint

If you prefer using n8n’s OpenAI nodes (which have more configuration options than the dedicated Ollama nodes), you can point them at Ollama’s OpenAI-compatible API. In n8n, create an OpenAI credential with the following settings: API Key (any non-empty string — “ollama” works), and Base URL set to http://localhost:11434/v1 (or http://host.docker.internal:11434/v1 from Docker). With this credential, all of n8n’s OpenAI nodes — including the more powerful ones with more configuration options — connect to your local Ollama instance. The model name in each node should match an Ollama model you have installed (e.g. llama3.2 rather than gpt-4o). This approach gives you access to n8n’s full suite of OpenAI-compatible nodes while keeping inference local, and it’s useful when you’re adapting an existing n8n workflow that was built for the OpenAI API to run locally instead. The feature parity between the OpenAI and Ollama nodes in n8n is growing, so the dedicated Ollama nodes are increasingly the better default — but the OpenAI-compatible path remains a useful fallback when you need specific capabilities the Ollama nodes haven’t yet implemented.

Understanding both integration paths — the native Ollama nodes and the OpenAI-compatible route — means you’re never stuck when a particular workflow pattern requires one approach over the other, and gives you the flexibility to adopt whichever n8n updates bring the best Ollama support as both tools continue to develop.

Scaling Up: From Single Workflows to an Internal AI Platform

Once you have a handful of working n8n + Ollama workflows, it’s natural to think about making them more broadly accessible within your team or organisation. n8n supports webhook triggers that can be called from any HTTP client — meaning you can build an internal API surface where other tools, scripts, or web apps trigger AI workflows without needing direct access to the n8n UI. A Slack bot that triggers a summarisation workflow, a web form that runs a document classification workflow, or a scheduled report that runs nightly against new database entries — all of these are straightforward to build once you have the n8n + Ollama foundation working. The combination scales well: Ollama handles inference, n8n handles orchestration and integration, and you retain full control over what runs where and what data is processed. Adding authentication to your n8n webhooks (using n8n’s built-in header auth or webhook signatures) ensures only authorised callers can trigger your workflows, which matters once you’re building workflows that take meaningful actions rather than just generating text. This architecture — n8n as the workflow brain, Ollama as the AI inference layer, your existing tools and databases as the integration targets — is a practical foundation for a self-hosted internal AI platform that costs nothing in per-call fees and keeps your data entirely within your infrastructure.

Leave a Comment