How to Connect n8n with Local LLMs for Free Workflow Automation
Workflow automation usually comes with a monthly bill twice over: once for the automation platform and once for the AI API calls inside it. Connecting n8n to a local large language model removes the second bill entirely. n8n is a visual workflow automation platform that runs on your own machine, and Ollama runs open source language models locally on the same machine. Put them together and you get AI powered automation with no per token cost, no rate limits, and no data leaving your network.

This guide shows how to connect n8n with local LLMs for free workflow automation in 2027, using Docker Compose, Ollama, and models like Llama 3.2 and Qwen3. You will build a working stack in about 20 minutes, fix the one networking mistake that breaks most first setups, and finish with a real workflow that summarizes an RSS feed using a model running on your own hardware.
Share:
Why n8n Plus a Local LLM Is the Cheapest AI Automation Stack
n8n plus a local LLM is the cheapest AI automation stack because both halves are free and self hosted. n8n is open source workflow software with a visual node editor: you drag nodes onto a canvas, connect them, and the workflow runs. Ollama is a free tool for running large language models locally, including Llama 3.2, Mistral, and Qwen3, and it exposes a clean REST API on port 11434 that n8n can call directly. Neither charges per request, so a workflow that runs a thousand times a day costs the same as one that runs once: the electricity for your own machine.
Privacy is the second reason this stack matters. Every prompt you send to a cloud API leaves your network and may be logged or used for training, depending on the provider’s terms. A local model keeps your emails, documents, and customer data on your own hardware, which is the difference between an automation you can use for client work and one you cannot. The third reason is control: local models have no rate limits, no downtime from a provider outage, and no surprise price changes.
A realistic example shows the saving. A freelancer who classifies 200 customer support emails a day through a cloud API at a few cents per call pays roughly 100 to 200 dollars a month in API fees alone. The same workflow on a local Qwen3 8B model costs nothing per call after the one time setup. The trade off is hardware: you need a machine with at least 8 GB of RAM and enough disk space for the model, and the local model is slower and less capable than the frontier cloud models. The takeaway is that local LLMs are the right choice for high volume, privacy sensitive, or always on automation, and cloud APIs remain better for one off tasks that need the smartest model available. If you are new to local models, our guide to running DeepSeek and Llama models locally on a low end PC covers the basics.

What You Need Before You Start
You need three things before you start: Docker with Compose version 2, enough memory for a model, and about 20 minutes. Docker Desktop works on macOS and Windows, and Docker Engine plus the Compose plugin works on Linux. n8n’s own installation pages now recommend Docker Compose over a single docker run command, because Compose creates a private network where the services can reach each other by name.
Memory decides which model you can run. Llama 3.2 3B is a 2.0 GB download and Llama 3.2 1B is 1.3 GB, according to the Ollama library, and both run comfortably on a machine with 8 GB of RAM. Qwen3 8B needs more memory but supports tool calling, which matters for agent workflows. A GPU speeds up generation significantly, but it is not required: CPU inference works for short prompts and low volume workflows. Disk space matters too, because each model is a multi gigabyte download and you will likely try several.
The practical takeaway is to start small. Pull Llama 3.2 3B first, prove the connection works, and only then move to a larger model. A 3B model is enough for classification, summarization, and extraction, which are the most common automation jobs. You can always swap the model later without rebuilding the workflow, because n8n reads the available models from Ollama’s API. For a full local AI setup, n8n also maintains a Self hosted AI Starter Kit, a Compose template that bundles n8n, Ollama, the Qdrant vector store, and PostgreSQL.
Step 1: Run n8n and Ollama With Docker Compose
Docker Compose is the recommended way to run n8n and Ollama together, because it puts both services on one private network where they can reach each other by service name. Create a file called docker-compose.yml with the following content. This setup is checked against n8n’s and Ollama’s official documentation as of October 2026.
services:
ollama:
image: ollama/ollama
container_name: ollama
restart: unless-stopped
ports:
- "11434:11434"
volumes:
- ollama:/root/.ollama
n8n:
image: n8nio/n8n
container_name: n8n
restart: unless-stopped
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- ollama
volumes:
ollama:
n8n_data:
Start the stack with docker compose up -d, then open n8n at http://localhost:5678 in your browser. The first time you open n8n it asks you to create an owner account. That account is local to your machine, so use a password you will remember, and keep it safe, because anyone who can reach your n8n instance can run workflows with your credentials.
The takeaway from this step is that Compose does the networking for you. Both containers share a private network, and each service is reachable by its service name. That detail is the key to the next steps, and it is the detail most tutorials skip. For more on running AI locally, see our guide to the best offline AI tools that work without an internet connection.
Step 2: Pull a Model Into Ollama
Pulling a model downloads it into the Ollama container so n8n can use it. Run this command to pull Llama 3.2 3B, a 2.0 GB download that balances speed and capability for most homelab hardware:
docker compose exec ollama ollama pull llama3.2:3b
Verify the model is installed and the API is responding with a quick test:
curl http://localhost:11434/api/tags
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2:3b",
"prompt": "Say hello in one sentence.",
"stream": false
}'
If you plan to use the AI Agent node, pull a model that supports tool calling instead. Qwen3 8B is the usual recommendation, and it is marked as supporting tools on the Ollama model library. Pull it with docker compose exec ollama ollama pull qwen3:8b. For retrieval augmented generation workflows, also pull an embedding model such as bge-m3, which turns text into searchable vectors. The takeaway is to match the model to the job: a small model for classification and summarization, a tool calling model for agents, and an embedding model for search. You can list installed models at any time with the tags endpoint above.
Step 3: Get the Networking Right (the Localhost Pitfall)
The localhost pitfall is the most common reason n8n cannot reach Ollama, and it breaks most first setups. Inside a Docker container, localhost means the container itself, not your computer. When n8n runs in a container and you tell it Ollama is at http://localhost:11434, n8n looks inside its own container, finds nothing on port 11434, and the connection fails. The fix is to use the address that matches your layout.
| Where Each Part Runs | Base URL in the n8n Credential |
|---|---|
| n8n and Ollama in the same Compose project | http://ollama:11434 |
| Both installed directly on the same computer | http://localhost:11434 |
| n8n in Docker, Ollama on the host (Windows or Mac) | http://host.docker.internal:11434 |
| n8n in Docker, Ollama on the host (Linux) | http://host.docker.internal:11434, plus add host gateway to the container |
| Ollama on another computer | http://that-computer-IP:11434 |
One more detail matters on Linux: Ollama listens only on 127.0.0.1 by default, so Docker containers may not be able to connect even with the right URL. Set the OLLAMA_HOST environment variable to 0.0.0.0 and use a firewall to block external connections. In n8n, create the credential by selecting Ollama Chat Model in the Chat Model slot of an AI node, entering the base URL from the table, and saving. n8n tests the connection when you save, and after it succeeds you can find your downloaded models in the Model dropdown.
The takeaway is simple: if the connection test fails, the URL is almost always the problem, not the model. Check the table, confirm both containers are on the same network, and test the Ollama API from your host machine with curl before debugging anything in n8n. For a related local connection guide, see our tutorial on connecting Claude AI to local files using MCP.

Step 4: Build Your First Workflow (RSS Summarizer)
Your first workflow should be simple enough to finish in 10 minutes and useful enough to keep running. An RSS summarizer is the ideal example: it reads a feed every hour, has the local model summarize each new item, and posts the summaries to a webhook. It needs five nodes: Schedule Trigger, RSS Read, Limit, Basic LLM Chain with an Ollama Chat Model, and HTTP Request.
Build it in order. Add a Schedule Trigger set to run every hour. Add an RSS Read node pointed at a feed you follow. Add a Limit node set to 5 items so the first run does not summarize a hundred old posts. Add a Basic LLM Chain node, set its Chat Model to Ollama Chat Model with llama3.2:3b, and give it a prompt such as “Summarize the following article in two sentences, naming the key fact.” Finally, add an HTTP Request node that posts the summary to a webhook, or a Slack or Telegram node if you want the summaries delivered to you.
Use the Basic LLM Chain node when you do not need tools, because it is simpler and faster than the AI Agent node. The AI Agent node is for jobs that need tools, such as searching the web, querying a database, or calling an API, and n8n’s documentation says at least one tool sub node must be connected to it. A practical example of the finished workflow: every morning you wake up to five two sentence summaries of the overnight AI news, generated by a model on your own machine, at zero cost. The takeaway is to start with a chain, not an agent, and to add tools only when a workflow actually needs them.
Step 5: Practical Workflows Worth Building Next
Once the RSS summarizer works, the same pattern extends to almost any text job. A customer support email classifier reads Gmail, classifies each email as a pricing inquiry, an order issue, a complaint, or other, and routes it with a Switch node. A meeting notes processor takes a transcript, extracts decisions and action items, and writes them to a document. A content repurposer takes a blog post and turns it into social media drafts. All three use the same nodes: a trigger, a Basic LLM Chain with a local model, and a destination.
The workflows that save the most time share two traits. They run on a schedule or a trigger without human input, and they handle text that would otherwise be read and sorted by a person. A freelancer who automates client onboarding, invoice reminders, and email triage can save several hours a week, and the local model means the automation costs nothing to run at volume. The limit is model capability: a 3B model classifies and summarizes well but writes mediocre long form content, so keep the generation tasks short and factual.
The takeaway is to automate the boring text jobs first and the creative jobs last. Start with classification, summarization, and extraction, which local models do reliably. Move to drafting and writing only after you have tested the model’s output quality on your own content. For more automation ideas, see our guide to automating Google Sheets with free AI agents and our list of open source GitHub repositories for AI agents and automation.
Troubleshooting the Five Most Common Problems
Five problems cover nearly every failed n8n and Ollama setup, and each has a fast fix. First, the connection test fails: the base URL is wrong for your layout, so check the table in Step 3. Second, the model dropdown is empty: the credential saved but Ollama has no models installed, so pull one with the command in Step 2 and refresh. Third, the workflow runs but the model returns an empty response: the prompt is too long for the model’s context window, so shorten it or switch to a larger model.
Fourth, generation is very slow: the model is running on CPU, which is normal for large models on machines without a GPU. Switch to a smaller model such as llama3.2:1b for testing, or add GPU support to the Ollama container with the NVIDIA container runtime. Fifth, n8n cannot see the Ollama container at all: the containers are on different networks, which happens when you start them with separate Compose files or separate docker run commands. Put them in one Compose project so they share a network.
The takeaway is to debug in order: confirm Ollama responds to curl on the host, confirm the containers share a network, confirm the base URL matches the layout, and only then look at the workflow itself. Most problems are networking, not AI. Once the stack is running, it is reliable: local models do not go down, do not change their pricing, and do not rate limit you, which is the whole point of building automation on your own hardware in 2027.

Don’t Miss These, Explore More Topics









