# In n8n I can't connect ollama chat model. What should I do?

**URL:** <https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381>\
**Category:** Questions\
**Created:** [May 21, 2025, 6:30am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381 "2025-05-21T06:30:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohsenet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohsenet/32/83136_2.png) [@mohsenet](https://community.n8n.io/u/mohsenet)\
**Post date:** [May 21, 2025, 6:30am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/1 "2025-05-21T06:30:07Z")

</div>

When I select ollama model chat, in the test to connect’ I get following error with “[http://localhost:11434](http://localhost:11434)” address. What should I do? Also servis is run and OK and its API is working without n8n.

“”"  
Couldn’t connect with this setting  
“”"

---

<div class="post-metadata">

**Author:** ![darrell\_tw](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/darrell_tw/32/52180_2.png) [@darrell\_tw](https://community.n8n.io/u/darrell_tw)\
**Post date:** [May 21, 2025, 6:36am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/2 "2025-05-21T06:36:05Z")

</div>

Where did you host your n8n?

If you are using **cloud version**. You can not just use the `localhost` domain.

You might need something like ngrok to let your localhost has a domain that can be connected from outside.

---

<div class="post-metadata">

**Author:** ![mohsenet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohsenet/32/83136_2.png) [@mohsenet](https://community.n8n.io/u/mohsenet)\
**Post date:** [May 21, 2025, 6:40am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/3 "2025-05-21T06:40:03Z")

</div>

Thanks @darrell_tw to answer 🙏

But I ran it in locally.

---

<div class="post-metadata">

**Author:** ![darrell\_tw](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/darrell_tw/32/52180_2.png) [@darrell\_tw](https://community.n8n.io/u/darrell_tw)\
**Post date:** [May 21, 2025, 7:25am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/4 "2025-05-21T07:25:44Z")

</div>

> [@mohsenet](#):
>
> Couldn’t connect with this setting

Ah ok. So the error message is only `Couldn’t connect with this setting`?

---

<div class="post-metadata">

**Author:** ![mohsenet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohsenet/32/83136_2.png) [@mohsenet](https://community.n8n.io/u/mohsenet)\
**Post date:** [May 21, 2025, 8:21am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/5 "2025-05-21T08:21:33Z")

</div>

![Screenshot_20250521_092356_Claude](https://europe1.discourse-cdn.com/n8n/original/3X/a/d/ad175dc7f8ddb3db2e2313db9b1e247ce931b4eb.jpeg)

---

<div class="post-metadata">

**Author:** ![Franz](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/franz/32/66008_2.png) [@Franz](https://community.n8n.io/u/Franz)\
**Post date:** [May 21, 2025, 10:40am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/6 "2025-05-21T10:40:45Z")

</div>

When your n8n runs inside a docker you can try to use `http://host.docker.internal:11434`.  
When ollama also runs inside a docker you can use `http://ollama:11434`, depends on the container name.  
If it doesn’t work please share your setup(How you start n8n and ollama)

---

<div class="post-metadata">

**Author:** ![mohsenet](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohsenet/32/83136_2.png) [@mohsenet](https://community.n8n.io/u/mohsenet)\
**Post date:** [May 21, 2025, 6:31pm UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/7 "2025-05-21T18:31:36Z")

</div>

@Franz , I do that but it doesn’t work. Can this photo help?

 ![n8n](https://europe1.discourse-cdn.com/n8n/original/3X/6/b/6b7fa7d5a13fcd296e3a9325b9de6ce883fdcc19.png)

---

<div class="post-metadata">

**Author:** ![Franz](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/franz/32/66008_2.png) [@Franz](https://community.n8n.io/u/Franz)\
**Post date:** [May 22, 2025, 5:34am UTC](https://community.n8n.io/t/in-n8n-i-cant-connect-ollama-chat-model-what-should-i-do/118381/8 "2025-05-22T05:34:00Z")

</div>

When `http://host.docker.internal:11434` does not work, you can try to add `extra_hosts` to your docker compose file.  
This is probably only necessary when Docker is running on Linux Machines.

```auto
services:
  n8n:
    image: n8nio/n8n
    environment: 
        - N8N_COMMUNITY_PACKAGES_ALLOW_MODE_USAGE=true
    container_name: n8n
    ports:
      - 5678:5678
    columes:
      - n8n_data:/home/node/.n8n
    restart: unless-stopped
    extra_hosts:
      - "host.docker.internal:host-gateway"

volumes:
  n8n_data:

```

If it doesn’t work you can also set `network_mode: host` in your n8n docker compose file and change the url to `http://localhost:11434` or `[http://127.0.0.1:11434](http://127.0.0.1:11434).

My recommendation is to run both services in a single Docker Compose setup. This way, you can use `http://ollama:11434`.

```auto
version: "3.8"

services:
  ollama:
    image: ollama/ollama
    volumes:
      - ollama:/root/.ollama
    ports:
      - "11434:11434"

  n8n:
    image: n8nio/n8n
    container_name: n8n
    environment:
      - N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
    ports:
      - "5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n
    restart: unless-stopped

volumes:
  ollama:
  n8n_data:

```

You can start individual services with `docker compose up service_name`, e.g. `docker compose up n8n` or `docker compose up ollama`
