← Back to Blog

n8n and Ollama: Run AI Workflows on Your Own Hardware, and Know Which Jobs a Local Model Can't Do

Connecting n8n to Ollama takes an afternoon and removes the per-run AI bill. Here is the setup, the two settings behind most failed builds, and an honest split of which jobs to run locally and which to keep on a cloud model, as of November 2026.

Tools12 min read•

n8n and Ollama: free AI runs, with a catch that never makes the thumbnail

An agency owner with 40 client workflows on a cloud model watches the API bill grow every month, so the pitch lands hard: install Ollama, point n8n at it, pay $0 per run forever. It is a real setup. One builder documented on this site runs file processing, blog posting and GitHub pushes on n8n with local models for $0 a month in API fees.

The catch is that a small local model is good at sorting, extracting and summarizing, and unreliable at the thing most people mean by "agent": picking between several tools and chaining steps on its own. This guide covers how to connect n8n and Ollama, which jobs to hand a local model, which to keep on a cloud model, and the two settings behind most of the "it doesn't work" forum posts.

What the documented builds did

A Self Hosted AI Automation Stack Running n8n, Local LLMs, and Docker for $0 per Month (builtwithagents.ai/strategy/self-hosted-ai-automation-n8n-docker-local-llms-zero-cost) describes one server running n8n with Ollama and LM Studio under Docker Compose. With only local models the stack costs $0 a month, and because nothing is priced per run, workflow executions are unlimited. The builder still kept OpenRouter wired in as an optional, pay-per-use route to outside models. Hold on to that detail. It is the pattern this guide recommends.

Running Multiple $10K MRR Products Solo on a $20 per Month Stack and a Used GPU covers a veteran solo founder who sends batch AI work to a used $900 graphics card instead of paying API fees. The revenue figures are self-reported. The useful word is "batch": work where nobody is sitting there waiting for the answer.

What a local model is good at, and where it falls over

A model small enough to run on an office computer handles single-step jobs well. Put one thing in, get one thing out: tag an email as one of six categories, pull the name, phone number and job type out of a form, summarize a call transcript, draft a reply that a person will read before it goes anywhere.

It struggles when it has to run the show. n8n's documentation says that since version 1.82.0 every AI Agent node works as a Tools Agent, which means the model has to produce properly structured tool calls, not prose. Threads on n8n's community forum describe the same failures again and again with local models: the model writes out the tool call as plain text and nothing fires, a model that carries a tools tag still skips the tool, or the second tool in a chain never runs on 7B and 14B models. One user's fix was to give each agent exactly one tool. Those are user reports, not benchmarks, but they are consistent, and people in the same threads say the identical workflow runs fine on a large cloud model.

So split the work. Local for the high-volume, low-judgment steps. Cloud for the steps where a wrong move reaches a customer.

Which jobs to run on a local model, and which to send out Job Where to run it Why Sort and tag messages One input, one label Local model (3B to 8B) Small models do this well Extract fields to JSON Forms, emails, transcripts Local model + output parser Private data stays in house Summaries and drafts A person approves them Local, run as a batch Nobody is waiting on it Agent with one tool Look up, then answer Local, after 20 test runs Works, but verify it Agent with many tools Multi-step, live customer Cloud model Small models drop steps

The two settings behind most failed setups

The first is context length, which is how much text the model can hold at once. Ollama's documentation says the default depends on your graphics memory, and on anything under 24 GiB of VRAM the default is 4k tokens. A system prompt plus tool definitions plus one long email can pass that, and the model then quietly forgets your instructions. Ollama recommends at least 64,000 tokens for agents, web search and coding tools, and warns that a larger context uses more memory. You change it with the context length slider in the Ollama app's settings, or by starting the server with OLLAMA_CONTEXT_LENGTH set to the number you want.

The second is the base URL. Ollama listens on 127.0.0.1 port 11434 by default. If n8n runs in Docker, "localhost" inside the container means the container, not your computer, so the connection is refused. n8n's docs list the fix for each layout. If only n8n is in Docker, use http://host.docker.internal:11434 (on Linux, start n8n with the flag --add-host host.docker.internal:host-gateway and have Ollama listen on 0.0.0.0). If both are in separate containers, put them on the same user-defined Docker network and use http://ollama:11434, with your container's name in place of "ollama". If you see the error "connect ECONNREFUSED ::1:11434", swap localhost for http://127.0.0.1:11434, because your machine tried IPv6 and Ollama is listening on IPv4.

A worked example: an insurance agency's intake sorter

Picture a five-person independent insurance agency that gets about 60 web form submissions a day: quote requests, claims, policy changes, billing questions. The forms contain birth dates and driver's license numbers, and the owner does not want them sent to an outside AI service.

A spare office computer with 16 GB of memory runs Ollama with the qwen3 8B model, a 5.2 GB download that carries Ollama's tools tag. n8n's free Community Edition runs on the same machine. A Webhook node receives each form. A Basic LLM Chain node with the Ollama Chat Model attached, plus a Structured Output Parser, returns four fields: request type, line of insurance, urgency and a one-line summary. A Switch node routes on the request type. Claims go to the owner by text right away. Quote requests become a row in the tracker with a draft reply saved for a licensed agent to review and send.

There is no agent loop and no tool choice, which is why it works on a small model. Each form takes somewhere between a few seconds and a minute depending on the hardware, and nobody is waiting on it. The running cost is electricity. Ollama's FAQ states that when you run locally it does not see your prompts or data. The honest caveat: the form data still passes through your website host on the way in, so local AI closes one door, not all of them.

Step by step: connect n8n to Ollama

Step 1: Install Ollama and pull a model with the tools tag

Download Ollama from ollama.com for Mac, Windows or Linux. In a terminal, run: ollama pull qwen3:8b. If the machine is small, pull llama3.2 instead, a 2.0 GB download at the 3B size that is fine for sorting and tagging. A rough rule: the model file should fit in your memory with several gigabytes to spare. Only pick models that show the tools tag in Ollama's library if you plan to use the AI Agent node.

Step 2: Raise the context length

Open the Ollama app's settings and move the context length slider up, or start the server with OLLAMA_CONTEXT_LENGTH=64000 if your hardware can take it. Then load the model and run: ollama ps. Check two columns. CONTEXT should show the number you set. PROCESSOR should say 100% GPU if you have a graphics card; a CPU share there means the model spilled into system memory and will be slow. If it spilled, lower the context or use a smaller model.

Step 3: Get n8n running next to it

If you already self-host n8n, skip ahead. If not, n8n publishes a Self-hosted AI Starter Kit on GitHub under the Apache 2.0 license that bundles n8n, Ollama, the Qdrant vector store and PostgreSQL. Clone the repository, copy .env.example to .env, then run docker compose --profile cpu up, or --profile gpu-nvidia on a machine with an Nvidia card. It downloads Llama 3.2 on first start. Open http://localhost:5678 to create your n8n login. On a Mac, Docker cannot use the Mac's graphics chip, so the kit's instructions suggest running Ollama on the Mac itself and setting OLLAMA_HOST to host.docker.internal:11434 in the .env file.

Step 4: Create the Ollama credential with the right base URL

In n8n, add a credential of type Ollama and set the base URL using the layout rules above. This single field causes most connection errors. Add an Ollama Chat Model node to a blank workflow, open the model dropdown and confirm your pulled models appear. If the list is empty, the URL is wrong. Use the Ollama Chat Model node, not the plain Ollama Model node, because agents and tools need the chat version.

Step 5: Build a one-step workflow before any agent

Start with the pattern from the example: a trigger, a Basic LLM Chain with the Ollama Chat Model, and a Structured Output Parser that defines the exact fields you want back. Write the prompt like a form: "Classify this message as exactly one of: new quote, claim, policy change, billing, other. Return urgency as high or normal. Summarize in one sentence." Short, closed instructions suit small models.

Step 6: Test on 30 real inputs

Paste in 30 real messages from last month and compare the output with what a staff member would have chosen. Count the misses. If more than two or three are wrong, tighten the categories, add two examples to the prompt, or move up one model size. Do not put it into daily use until you have done this count.

Step 7: Add an agent with one tool, and a cloud route for the hard steps

When the one-step version is steady, try an AI Agent node with the Ollama Chat Model and a single tool, such as a lookup in your customer sheet. Run it 20 times and read every run in the execution log to confirm the tool fired. For anything with several tools or a live customer on the other end, attach a cloud chat model to that one agent instead. A builder on this site kept OpenRouter for exactly that. You still save on every high-volume step.

What this costs

As of November 2026: Ollama's pricing page lists local use at $0, and its FAQ says running models on your own hardware is always unlimited. Ollama also sells hosted cloud models, billed per token on the $0 plan or through a Pro plan at $20 a month that includes $60 of usage credits, which is a middle path if your hardware is weak. n8n's Community Edition is free to self-host; it leaves out features such as single sign-on, projects, workflow sharing and Git version control. n8n Cloud's Starter plan is 20 euros a month billed annually for 2,500 executions, but a cloud-hosted n8n cannot reach an Ollama server that only listens on your office computer, so local models pair best with self-hosted n8n.

Hardware is the real cost. Use a machine you already own for the first month. The founder documented above bought a used $900 graphics card only once the batch volume justified it. Budget an afternoon for setup and remember that updates, backups and restarts are now your job.

When not to run local

If your cloud AI bill is $15 a month, do not bother. You would trade a small bill for a maintenance chore. Do not put a small local model in front of live customers on chat or phone, where slow or wrong answers cost you jobs. Do not run a multi-tool agent on it and assume it works because it did once. And if nobody on your team is comfortable restarting a Docker container, the savings will not survive the first outage. Local makes sense for three cases: private data you do not want leaving the building, high-volume batch work, and experiments you want to run thousands of times without watching a meter.

Frequently Asked Questions

Is Ollama free to use with n8n?▾

Yes for local use. As of November 2026 Ollama lists running models on your own hardware at $0 with no usage limit, and n8n's self-hosted Community Edition is free. You pay for hardware and electricity, plus any cloud models you choose to add.

Can n8n connect to Ollama?▾

Yes. n8n has an Ollama Chat Model node that attaches to chains and to the AI Agent node. You create an Ollama credential with the server's base URL, which is http://localhost:11434 when both run directly on the same machine.

Why does n8n say connection refused when I add Ollama?▾

Usually n8n is in Docker and "localhost" points at the container. Use http://host.docker.internal:11434, or the Ollama container's name if both are in Docker on the same network. For the error ending in ::1:11434, use http://127.0.0.1:11434.

Which Ollama model works best with the n8n AI Agent?▾

There is no single winner. Pick a model with the tools tag in Ollama's library, since n8n agents rely on tool calling. Users on n8n's forum report better results after moving to the qwen3 family, and unreliable tool use on very small models. Test yours 20 times before trusting it.

Can n8n Cloud use a local Ollama model?▾

Not directly, because n8n Cloud cannot reach a server that only listens on your own computer. You would have to expose Ollama to the internet behind authentication, which most small teams should avoid. Self-hosting n8n on the same machine or network is simpler.

Is my data private when n8n uses Ollama?▾

The model step is. Ollama's FAQ says it does not see your prompts or data when you run locally. Data still passes through whatever feeds the workflow, such as your form provider or email service, so check those too.

Keep Reading

Explore Related Niches

Related Strategies

Marketing & SalesProfessional ServicesInternal Tool

A sales team of 10 SDRs and AEs was replaced by 20 AI agents managed by 1.2 humans, maintaining the same business performance.

Advanced$200+/moVery High ($10K+/mo)
View Strategy
Dev ToolsProfessional ServicesSaaS Product

A non developer learned to code using AI tools and built a portfolio of SaaS products generating $28K per month.

BeginnerUnder $50/moVery High ($10K+/mo)
View Strategy
Dev ToolsProfessional ServicesSaaS Product

A SaaS playbook combining Claude Code for development and Google Search for distribution reached $40K MRR in 7 months.

IntermediateUnder $50/moVery High ($10K+/mo)
View Strategy

Keep Exploring the Directory

Browse more case studies, compare tools, or dig into the full tool stack behind these workflows.

Want more strategies like this?

Get weekly AI agent case studies in your inbox.