Why Self-Hosted AI Workflow Automation Matters

Cloud-based AI services introduce significant drawbacks: unpredictable latency, ongoing subscription costs, data privacy concerns, and vendor lock-in [S1]. For developers and sysadmins managing sensitive data or requiring predictable performance, self-hosted alternatives are essential [S2].

This guide demonstrates how to combine n8n visual workflow builder with Ollama local LLM serving to create a complete offline AI automation pipeline. The stack requires no cloud accounts, no API keys, and sends no data external to your infrastructure.

Prerequisites and Hardware Checklist

Before deploying the stack, verify your environment meets the minimum requirements:

  • Docker and Docker Compose: Both must be installed and running. Docker Compose v2 is included with Docker Desktop; on Linux, use the docker-compose or docker compose command [S1].
  • Minimum 8GB RAM: n8n plus Ollama plus one 7B-parameter model comfortably fits in 8GB; 16GB+ allows running larger models or multiple concurrent workflows.
  • Disk space: A 7B GGUF model needs approximately 4.5GB; a 70B quantized model needs approximately 40GB [S2].
  • Network isolation: The pipeline should run behind a local firewall. Expose APIs only on 127.0.0.1 or a VPN. Never expose Ollama or n8n directly to the public internet without a reverse proxy and TLS.
  • Rollback plan: Use Docker containers so you can destroy and rebuild the environment in minutes. Document your environment variables and model selections [S3].

Layer 1: n8n Visual Workflow Automation

n8n is a fair-code licensed workflow automation tool that combines AI features with business process automation [S1]. Its visual canvas lets you drag nodes together to create complex AI-powered workflows without writing code from scratch.

Key n8n Features for AI Workflows:

  • AI Agent node: Connect to any LLM provider, including locally-hosted Ollama models, to add generative AI steps in your workflows [S1].
  • 500+ pre-built integrations: Connect n8n to databases, APIs, file systems, email, and more. When self-hosted, all integrations run on your infrastructure [S1].
  • Human-in-the-loop approvals: Insert approval nodes that pause workflow execution until a human reviews and confirms the AI output [S1].
  • Error handling and retries: Built-in error nodes, retry logic, and execution branching ensure robust automated pipelines [S1].
  • Workflow export/import: Share workflows as JSON files or export them version-controlled via Git [S3].

Why n8n Over Alternative Workflow Tools

Compared to Zapier or Make.com, n8n fair-code license allows self-hosting without per-execution fees. Compared to Airflow, n8n visual canvas and AI-native nodes make it accessible for non-engineers. Compared to AWS Step Functions, self-hosted n8n eliminates vendor lock-in and ongoing costs [S1].

Layer 2: Ollama Local LLM Serving

Ollama lets you use open models with your coding agents so you can spend less while keeping your data private [S2]. It packages open-source LLMs into convenient Docker containers with a simple API.

CPU-Only Deployment

Run Ollama with the standard Docker command [S2]:

“bash docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama “

This starts Ollama on port 11434, accessible locally. The ollama volume persists model data between container restarts [S2].

NVIDIA GPU Acceleration

For systems with NVIDIA GPUs, install the NVIDIA Container Toolkit first [S2]:

“bash sudo docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama “

Pulling and Running Models

“bash ollama pull phi3:latest ollama run phi3 Explain the benefits of local AI curl -X POST http://127.0.0.1:11434/api/chat -H Content-Type:application/json -d model:phi3:latest “

Layer 3: Connecting n8n to Ollama

The integration between n8n and Ollama is accomplished through n8n AI Agent node, which supports connecting to any LLM provider via API [S1].

Step 1: Verify Ollama is Running

“bash curl -s http://127.0.0.1:11434/api/tags | python3 -m json.tool “

This should return a JSON list of installed models [S2].

Step 2: Configure the AI Agent Node

  1. Open n8n in your browser at http://localhost:5678
  2. Create a new workflow and add an AI Agent node
  3. In the AI Agent node settings:

– AI Model: Select Custom API – API Base URL: http://127.0.0.1:11434 – Model: phi3:latest – Authentication: None (local)

  1. Test the connection [S1].

Step 3: Build an AI Automation Workflow

Example workflow for an AI-powered email summarizer:

  1. Trigger: Receive new email in Gmail node
  2. AI Agent: Use the Ollama model to summarize the email body
  3. AI Agent: Classify the email urgency
  4. Conditional: Route based on urgency level
  5. SMTP: Send a summarized response

Each node runs entirely on your infrastructure [S1][S2].

Security and Compliance

All data processing occurs on-premises. No customer data, prompts, or outputs are sent to cloud APIs [S2]. This is critical for organizations subject to GDPR, CCPA, or HIPAA regulations.

Network Hardening

  • Run n8n and Ollama on a dedicated DMZ or isolated VLAN
  • Use a reverse proxy with TLS termination
  • Restrict database and Redis access to the Docker network only
  • Enable n8n built-in authentication and secret management [S1]

Rollback and Maintenance

Rolling Back a Model Version

“bash ollama list ollama pull phi3:2.7 “

Stopping and Restarting the Stack

“bash docker compose -f n8n-docker-compose.yml down docker compose -f n8n-docker-compose.yml up -d “

Updating n8n and Ollama

“bash curl -fsSL https://raw.githubusercontent.com/n8n-io/n8n/master/docker/get-n8n-compose.yml -o n8n-docker-compose.yml docker compose -f n8n-docker-compose.yml up -d “

Cost Comparison

The initial hardware investment pays for itself quickly for moderate-to-heavy usage [S1][S2].

Conclusion

Self-hosted AI workflow automation with n8n and Ollama gives developers and sysadmins complete control over their AI pipelines, delivering tangible cost savings and privacy benefits that compound over time. By eliminating cloud dependencies, you remove recurring costs, data leakage risks, and vendor lock-in while maintaining or exceeding the capabilities of cloud-only alternatives [S1][S2][S3]. The result is an automation stack you fully own, fully understand, and fully control. This is the difference between renting AI capabilities from a cloud provider and building your own infrastructure for the long term.

Start your self-hosted AI automation today:

  1. Install Docker and Docker Compose
  2. Run the n8n Docker Compose setup (see n8n docs [S1])
  3. Install Ollama and pull your first model
  4. Connect the n8n AI Agent node to your local Ollama instance
  5. Build your first offline AI automation workflow

Sources

  1. [S1] n8n Documentation – Install with Docker Compose — n8n (2026-09)
  2. [S2] Ollama Documentation – Docker Deployment — Ollama (2026-09)
  3. [S3] n8n GitHub Repository – docker Directory — n8n (2026-08)