Communication Issue between N8N and Ollama on Ubuntu (installed on Windows)

Hello everyone,

I’m having a connection issue between N8N and Ollama and I need your help.


  • System: Ubuntu installed on Windows via WSL.
  • Ollama: Installed without Docker and running correctly (verified via http://localhost:11434/).
  • N8N: Installed via Docker.

Problem Encountered

When I try to create a workflow in N8N to communicate with Ollama, I get the following error:

NodeApiError: The service refused the connection - perhaps it is offline

Steps Already Taken

  1. I replaced “localhost” with the host IP obtained using the hostname -I command, resulting in:
  2. Ollama seems to be running correctly as I can access it via http://localhost:11434/ in my browser.

Hypotheses and Questions

  • It appears that N8N (running in Docker) cannot access Ollama (running outside of Docker). Could this be related to network configuration between Docker and WSL?
  • Are there any specific configurations needed to enable communication between these two services?
  • How can I check if the issue is due to a network configuration problem or another aspect of the communication between these services?

Additional Note

I have seen similar posts with potential solutions, but unfortunately, none of them have worked for my setup.

Thanks in advance for your help and suggestions!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Try http://host.docker.internal:11434

I’m using docker compose for n8n, my ollama instance is running on Windows and was able to connect with the above URL.

Hi @Jim_Le,

Thank you so much for taking the time to respond and for your suggestion.

I tried using http://host.docker.internal:11434 as you recommended, but unfortunately, it didn’t work for me. I received the following error:

NodeApiError: The connection cannot be established, this usually occurs due to an incorrect host (domain) value
AxiosError: getaddrinfo ENOTFOUND host.docker.internal
Error: getaddrinfo ENOTFOUND host.docker.internal

It seems like my setup is not recognizing host.docker.internal. Do you have any other ideas or suggestions on how I might resolve this?

Thanks again for your help!


Hmm I’m going to assume you’re not using docker-compose. You’ll need to add the --add-host=host.docker.internal:host-gateway flag.

docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n --add-host=host.docker.internal:host-gateway

If this doesn’t work, then I’m all out of ideas!

Thank you for your new suggestion @Jim_Le, it didn’t work but I was able to correct the problem using the “–network host” option. I don’t know if this is a good practice :confused:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.