πŸ“ Tutorials
Β· 3 min read

How to Self-Host n8n with Local AI Models (2026)


Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.

n8n is an open-source workflow automation tool. Ollama runs AI models locally. Together, they give you AI-powered automation with zero data leaving your network β€” no API keys, no cloud dependencies, no GDPR concerns.

Setup with Docker Compose

# docker-compose.yml
services:
  n8n:
    image: n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=changeme
    volumes:
      - n8n_data:/home/node/.n8n

  ollama:
    image: ollama/ollama
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama
    # For GPU support, add:
    # runtime: nvidia
    # environment:
    #   - NVIDIA_VISIBLE_DEVICES=all

volumes:
  n8n_data:
  ollama_data:
docker compose up -d

# Pull a model
docker exec ollama ollama pull qwen3:8b

# Access n8n at http://localhost:5678

Connect n8n to Ollama

In n8n:

  1. Go to Settings β†’ Credentials β†’ Add Credential
  2. Select Ollama API
  3. Set Base URL: http://ollama:11434 (Docker service name, not localhost)
  4. Test connection

Now you can use the Ollama Chat Model and Ollama Embeddings nodes in any workflow.

Example workflow: AI email classifier

Email Trigger β†’ Ollama (classify) β†’ Switch β†’ 
  β”œβ”€β”€ "urgent" β†’ Slack notification
  β”œβ”€β”€ "support" β†’ Create ticket in Linear
  └── "newsletter" β†’ Archive

The Ollama node prompt:

Classify this email as one of: urgent, support, newsletter, spam.
Respond with only the category name.

Subject: {{$json.subject}}
Body: {{$json.body}}

This runs entirely on your infrastructure. No email content is sent to OpenAI or any external service.

Example workflow: AI code review on PR

GitHub Trigger (PR opened) β†’ Get PR diff β†’ Ollama (review) β†’ Post comment on PR

Ollama prompt:

Review this code diff for:
1. Security vulnerabilities
2. Performance issues
3. Code style problems

Be specific and actionable. Format as a GitHub comment with markdown.

Diff:
{{$json.diff}}

Example workflow: Daily log summarizer

Schedule (9am) β†’ Read log files β†’ Ollama (summarize) β†’ Slack message

This replaces a Claude Code Routine with a fully self-hosted alternative.

Which model to use in n8n

TaskModelWhy
Classificationqwen3:8bFast, accurate for simple tasks
Summarizationqwen3:8bGood balance of speed and quality
Code reviewqwen3.5:27bBetter quality for complex analysis
Embeddingsnomic-embed-textPurpose-built for embeddings

For most automation tasks, qwen3:8b is sufficient. The tasks are usually simple (classify, summarize, extract) and don’t need frontier model quality.

n8n AI nodes reference

NodeWhat it does
Ollama Chat ModelSend prompts, get responses
Ollama EmbeddingsGenerate vector embeddings
AI AgentMulti-step reasoning with tools
AI ChainSequential LLM calls
Vector StoreStore and query embeddings
Text SplitterChunk documents for RAG

Self-hosted vs Zapier/Make

n8n + OllamaZapierMake
Data privacyβœ… Everything local❌ Cloud❌ Cloud
AI model choiceAny (local or API)Built-in onlyLimited
Cost$0 (self-hosted)$20-100/mo$9-29/mo
App integrations400+9,000+1,800+
Setup effortMedium (Docker)LowLow

The trade-off: n8n has fewer integrations but complete privacy and zero ongoing cost. For GDPR-sensitive workflows, it’s the only option that keeps all data on your infrastructure.

Hosting options

OptionCostBest for
Your machine (Docker)$0Development, testing
Contabo VPS$5-20/moProduction, always-on
Vultr VPS$5-20/moProduction, global locations
Railway$5-20/moEasiest deployment

For production, a VPS with 8-16GB RAM runs both n8n and Ollama comfortably with an 8B model.

Related: Zapier vs n8n vs Make AI Β· Ollama Complete Guide Β· Self-Hosted AI for Enterprise Β· AI GDPR Guide Β· Claude Code Routines Β· Best Hosting for AI Projects