I’m having a connection issue between N8N and Ollama and I need your help.
Context
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
AxiosError:
AggregateError:
Steps Already Taken
I replaced “localhost” with the host IP obtained using the hostname -I command, resulting in: http://172.20.204.93:11434.
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.
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?
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