Skip to content

How-ToOS

How to Use Ollama With n8n for Local AI Workflows

Run n8n in Docker, make Ollama listen on 0.0.0.0, and set the n8n Ollama credential's Base URL to http://host.docker.internal:11434. A Chat Trigger, Basic LLM Chain and Ollama Chat Model then make a first local AI workflow.

By , Editorial team

4 min read

How to Use Ollama With n8n for Local AI Workflows

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:

  1. 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.

  2. 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

  1. 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.

  2. Add a Basic LLM Chain node, which n8n describes as the node that sets the prompt the model uses.

  3. 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.

  4. 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.

The bottom line

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.

Sources

  1. 01n8n Docs, Ollama credentials
  2. 02n8n Docs, Ollama Chat Model common issues
  3. 03n8n Docs, Ollama Chat Model node
  4. 04n8n Docs, Docker installation
  5. 05n8n Docs, Chat Trigger node
  6. 06n8n Docs, Basic LLM Chain node
  7. 07n8n Docs, AI Agent node
  8. 08n8n Docs, Self-hosted AI Starter Kit
  9. 09Ollama, FAQ

About the author

Forge PC Staff

Editorial team

The shared byline for articles researched, written and edited by the Forge PC editorial team. How we source, check and correct our work is set out in our editorial policy.

More from Forge PC Staff

Read next

How to Connect a PS5 DualSense Controller to Your PC

How-To

How to Connect a PS5 DualSense Controller to Your PC

A PS5 DualSense connects to a Windows PC by USB-C or Bluetooth. PlayStation says haptics and the headset jack need a cable on PC; to pair wirelessly, hold Create and PS until the light bar blinks, then add it in Windows.

Forge PC Staff3 min

How to Stop Your PC Waking Up From Sleep on Its Own

How-To

How to Stop Your PC Waking Up From Sleep on Its Own

If Windows wakes itself up, run powercfg /lastwake to see why. Then use powercfg to list and disarm wake-capable devices, check wake timers and requests, turn off Allow wake timers, and look at your BIOS power settings.

Forge PC Staff3 min

Best Free Keyboard and Mouse Remapping Software for Windows

Best Picks

Best Free Keyboard and Mouse Remapping Software for Windows in 2026

PowerToys Keyboard Manager is the best free remapping tool for most people. SharpKeys makes permanent key swaps with nothing running in the background, X-Mouse Button Control handles mouse buttons and per-app profiles, and AutoHotkey covers macros.

Forge PC Staff4 min