Fetch failed on Ollama Node Despite Successful Container-to-Container Network Connection

Hello,

I am running n8n v1.98.2 in the ai-stack Docker environment and have a persistent fetch failed error that I cannot solve.

My Goal: Connect a Basic LLM Chain node to an Ollama Model node to communicate with a local Ollama service running in the same Docker Compose project.

The Error: I consistently get a fetch failed error with an empty error cause.

Here is a complete summary of my troubleshooting:

  1. Network Connectivity: The network connection between the containers is working. I have used docker exec to get a shell inside the n8n container and a wget --spider http://ollama:11434 command connects successfully and instantly with a 200 OK response.
  2. Timeout Issue: The problem is not a timeout. The fetch failed error occurs with both large models (llama3.2) and tiny models (tinydolphin:1.1b).
  3. DNS Issue: I tried adding the NODE_OPTIONS=--dns-result-order=ipv4first environment variable to my docker-compose.yaml for the n8n service and restarted the stack, but the error remains exactly the same.
  4. Node Installation: The n8n-nodes-ollama community node is correctly installed via the N8N_EXTENSIONS_INSTALL environment variable and the nodes appear in the n8n UI.

The core question is: Why is the Node.js fetch call inside the n8n node failing when a wget call from the exact same container to the exact same address succeeds?

This seems to be a very low-level issue. Any help or ideas would be greatly appreciated.

Hey @upland777 hope all is well.

What about native node, the AI Agent, if you connect it to the ollama, does it work?

Thanks for the reply, just figured out problem, the credentials for the Local Ollama Model was set to http://localhost:11434, which did not communicate with the Docker Network. Changed it to http://ollama:11434 and it works fine now, it also works with the dhcp ip of the server.

1 Like

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