Self-Host n8n with Local Ollama: Zero-Cost AI Workflows (2026)

Self-Host n8n with Local Ollama: Zero-Cost AI Workflows (2026)

I've been running n8n + Ollama locally for a few months. No OpenAI bill. No data leaving my network. The setup takes under 20 minutes — except for the Docker networking part, which cost me an hour the first time. This post skips the fluff.

What n8n and Ollama Do

n8n is a self-hostable workflow automation tool — Zapier, but you own the server. It connects triggers, logic, APIs, databases, and AI models via a visual node editor. Refer to the n8n Docs for official workflow node definitions.

Ollama is a local LLM runtime. It downloads model weights, loads them into memory, and exposes a REST API on port 11434. Any app that makes HTTP requests can talk to it. Grab the installer from the Ollama Download page.

Trigger → n8n → Ollama API (:11434) → Local LLM → Output

Real reasons to use this stack: no per-token cost, data stays local, works offline. The honest tradeoff: a 7B model on an M2 MacBook is slower and weaker than GPT-4o. Use local where privacy or cost matters; use cloud where quality ships to users.

Related Reading: When to Use Cloud LLMs Instead (Claude Code CLI vs Cursor)

Hardware Checklist

RAMWhat Runs
8 GB1B–3B models (llama3.2:3b, qwen2.5:3b)
16 GB7B models comfortably (llama3.1:8b, qwen2.5:7b)
32 GB+13B–30B; 70B+ needs a GPU on top

SSD is non-negotiable — models are 2–40 GB. Apple Silicon is great here: GPU and CPU share the same memory pool, so a 16 GB M2 runs 7B models faster than most 16 GB Intel machines.

Install Ollama and Pull a Model

macOS / Linux:

curl -fsSL https://ollama.com/install.sh | sh

Windows: grab the installer at ollama.com/download.

Confirm it's alive:

curl http://localhost:11434
# Returns: "Ollama is running"

Pull a model:

ollama pull llama3.2       # 3B — good for 8 GB
ollama pull qwen2.5:7b     # 7B — better quality, needs 16 GB
ollama pull codellama:7b   # Code-specific tasks

Quick test:

ollama run llama3.2   # Type a prompt. /bye to exit.
curl http://localhost:11434/api/tags   # Lists your pulled models

✅ Ollama running | ✅ Model pulled | ✅ API accessible

Read: Claude code CLI setup - Terminal AI Agent vs Cursor IDE

Run n8n with Docker Compose

I run Ollama directly on the host for GPU access. n8n lives in Docker. Here's my working docker-compose.yml:

version: '3.8'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    ports:
      - "5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n
    extra_hosts:
      - "host.docker.internal:host-gateway"  # Linux only

volumes:
  n8n_data:
docker compose up -d

Open http://localhost:5678, create your account (local, no cloud), and you're in.

✅ n8n running

Read: Open-Weight Reasoning Models vs. Proprietary APIs: Cost, Latency & Privacy Benchmark

Connect n8n to Ollama

Go to Settings → Credentials → Add Credential → Ollama.

The Base URL field is where people get stuck. Use this lookup matrix:

n8n LocationOllama LocationBase URL
Host machineHost machinehttp://localhost:11434
DockerHost machinehttp://host.docker.internal:11434
DockerDocker (same network)http://ollama:11434

Click Test. Green = connected. ✅

Fix Docker Networking

This is where Docker breaks most setups. Here's why: inside a container, localhost refers to the container itself — not your machine. So localhost:11434 looks for Ollama inside the container, where nothing is listening.

  • macOS / Windows (Docker Desktop): host.docker.internal resolves automatically. Just use it.
  • Linux: It doesn't exist by default. The extra_hosts line in the compose file above handles it. Check the Docker extra_hosts documentation for configuration syntax.
--add-host=host.docker.internal:host-gateway

If running both containers in Docker, put them on the same network and reference Ollama by service name (http://ollama:11434). Note that GPU passthrough in this scenario requires the NVIDIA Container Toolkit on Linux.

5 Workflows Worth Building

  1. Email summarizer: Gmail trigger → Ollama → log summary to Google Sheets
  2. Document summarizer: Drive PDF → extract text → Ollama → save back to Drive
  3. Content draft generator: Webhook (topic input) → Ollama → Notion
  4. RAG / knowledge base: Add Qdrant. Explore the pre-built n8n Self-Hosted AI Starter Kit to launch n8n + Ollama + Qdrant + PostgreSQL automatically.
  5. Private chat assistant: Telegram/Webhook → Ollama with custom system prompt → reply. Nothing touches a cloud API.

Troubleshooting Table

ErrorCauseFix
Connection refusedOllama not runningollama serve
localhost failsn8n is in DockerUse host.docker.internal:11434
host.docker.internal fails on LinuxMissing mappingAdd extra_hosts: host-gateway
Model not foundNot pulledollama pull <model>
Credential passes, workflow failsName mismatchRun ollama list — names must match exactly
Slow responsesModel too largeSwitch to Q4-quantized variant
OOM errorsNot enough RAMDrop to 3B model or add swap
Workflows lost on restartNo volumeMount n8n_data (in compose above)

Local vs Cloud

FactorOllama + n8nCloud API
Cost per callZeroPay per token
Data privacyYour machineProvider's servers
Offline useYes (after download)No
Setup effortHigherMinimal
Model quality7B–70B localFrontier models available
ScalingYour hardware ceilingEffectively unlimited

FAQ

Can I run n8n and Ollama for free?
Yes. n8n self-hosted is free under its fair-code license. Ollama is open source. Real costs are electricity and your hardware.

Open Source Cursor Alt for CLI

What URL does n8n use to reach Ollama?
Host-to-host: http://localhost:11434. Docker-to-host: http://host.docker.internal:11434.

Why does localhost fail inside Docker?
localhost inside a container is the container itself, not your host machine. Ollama runs on the host, creating a network mismatch. Use host.docker.internal.

Which model should I start with?
8 GB RAM → llama3.2:3b. 16 GB → qwen2.5:7b. Pick what fits in your free RAM after your OS takes its share.

Does n8n support Ollama natively?
Yes. Built-in credentials and an Ollama Chat Model node are available out of the box.

Comments