n8n is a workflow automation tool that you can host yourself, and it has built-in nodes for Ollama. That means you can build chatbots and automations that use a language model running on your own graphics card instead of a paid cloud API. n8n's documentation has a page of connection fixes, mostly because a Docker container can't see localhost on your PC. This guide is based on n8n's and Ollama's documentation; Forge PC hasn't tested every combination.
What you need
Ollama installed with at least one model downloaded. If you're new to it, start with how to run AI models locally with Ollama and LM Studio. How well a model runs depends on whether it fits in your graphics card's memory; see how much VRAM you need.
Docker. n8n's documentation says Docker Desktop is available for Windows, Mac and Linux and includes Docker Engine and Docker Compose.
Step 1: Start n8n in Docker
n8n's Docker guide creates a volume for your data and then starts the container:
docker volume create n8n_data
docker run -it --rm --name n8n -p 5678:5678 -e GENERIC_TIMEZONE="Europe/London" -e TZ="Europe/London" -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true -v n8n_data:/home/node/.n8n n8nio/n8n
n8n's guide splits the command across several lines and asks you to fill in your timezone; we've used Europe/London. The command publishes port 5678 and stores your workflows and credentials in the n8n_data volume so they survive restarts. Because the command publishes port 5678, open http://localhost:5678 in your browser to reach n8n.
Step 2: Let Docker reach Ollama
By default, Ollama listens on 127.0.0.1 port 11434, according to Ollama's FAQ. n8n's troubleshooting guide explains that inside Docker each container has its own localhost, so n8n in a container can't reach Ollama on your PC using localhost.
If only n8n is in Docker and Ollama runs normally on your PC, n8n says to:
Make Ollama listen on all interfaces by setting the OLLAMA_HOST environment variable to 0.0.0.0:11434. On Windows, Ollama's FAQ says to quit Ollama, add the variable in Edit environment variables for your account, then start Ollama again from the Start menu.
Use host.docker.internal instead of localhost in n8n. n8n says Docker Desktop sets this up automatically. On Linux, start the n8n container with --add-host host.docker.internal:host-gateway.
A security note: binding Ollama to 0.0.0.0 makes it reachable from other devices on your network, which is how Ollama's FAQ describes exposing it. Make sure your firewall only allows devices you trust. Our guide to sharing Ollama on your local network covers this.
If both Ollama and n8n run in Docker containers, n8n says to put them on the same user-defined bridge network (for example with docker network create n8n-ollama and docker network connect), then use the Ollama container's name as the host, such as http://ollama:11434. n8n warns that container names don't resolve on Docker's default bridge network.
Step 3: Add your Ollama credentials in n8n
Create an Ollama credential in n8n. It needs only a Base URL:
Setup | Base URL to use |
|---|
n8n and Ollama both installed normally | http://localhost:11434 (or http://127.0.0.1:11434)
|
n8n in Docker, Ollama on the PC | http://host.docker.internal:11434
|
Both in Docker on a shared network | http://<ollama-container-name>:11434
|
The API key field is optional. n8n says it's only needed when you connect through an authenticated proxy, such as Open WebUI.
If you see the error connect ECONNREFUSED ::1:11434, n8n says your PC is trying IPv6 while Ollama listens on IPv4. Change localhost to 127.0.0.1 in the Base URL.
Step 4: Build a simple chat workflow
Add a Chat Trigger node. n8n says it's for chatbots and other chat interfaces, and it must connect to an agent or chain node.
Add a Basic LLM Chain node, which n8n describes as the node that sets the prompt the model uses.
Attach an Ollama Chat Model sub-node to the chain, select your Ollama credential and pick the model you downloaded. The node's options include sampling temperature, Top K and Top P.
Open the chat and send a message. The reply comes from the model on your PC.
Want the model to call tools, such as searching or sending data elsewhere? Use the AI Agent node instead of the chain. n8n says you must connect at least one tool sub-node to an AI Agent node.
Keep Make Chat Publicly Available turned off while you're building; n8n recommends turning it on only when you're ready to publish the workflow, and it supports basic authentication or n8n user logins for the chat.
Step 5: Keep the model loaded
Ollama's FAQ says models stay in memory for five minutes by default, so the first message after a pause can be slow. Our guide to keeping Ollama models loaded explains how to change that. Other apps can use Ollama the same way through its API; see how to use Ollama's OpenAI-compatible API.
An all-in-one alternative
n8n also publishes a Self-hosted AI Starter Kit, a Docker Compose template that sets up n8n with Ollama, the Qdrant vector database and PostgreSQL. It's an alternative if you'd rather start from a ready-made template.
Our verdict
Run n8n in Docker, make Ollama listen on 0.0.0.0 with OLLAMA_HOST, and set the n8n Ollama credential's Base URL to http://host.docker.internal:11434. Then connect a Chat Trigger, a Basic LLM Chain and an Ollama Chat Model to build your first local AI workflow, and keep Ollama firewalled to your own network.