[GH-ISSUE #2603] Issue with anything-llm in connection with the port binding to an IP in a virtual docker network #48045

Closed
opened 2026-04-28 06:32:51 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @fukuro-kun on GitHub (Feb 20, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2603

Backgound

When I set up the Docker container of https://github.com/Mintplex-Labs/anything-llm, and started a conversation, I received the following error:

llama:streaming - could not stream chat. Error: connect ECONNREFUSED 172.17.0.1:11434

although OLLAMA_BASE_PATH='http://host.docker.internal:11434 was set in the .env and --add-host=host.docker.internal:host-gateway to docker run command for this to resolve was added.

System:

  • Ubuntu Mate 23.10
  • current docker image
  • ollama version is 0.1.20

Solution:

  • It should be clearer stated that ollama itself has a restriction to localhost and 127.0.0.1 by default and what steps need to be taken to make it work with docker environments. This means that the IP of the Host inside of the virtual docker network does not bind to port 11434 of the host system by default. It took me several hours to discover and fix this issue.

Steps to fix this:

  1. Edit the service file:
    Open /etc/systemd/system/ollama.service and add the following line inside the [Service] section:
    Environment="OLLAMA_HOST=0.0.0.0"
    (the IP can and should of course also be adapted to the respective personal situation, 0.0.0.0 works for all, though.)

  2. Once you’ve made your changes, reload the daemons using the command
    sudo systemctl daemon-reload

  3. and then restart the service with
    sudo systemctl restart ollama

Originally created by @fukuro-kun on GitHub (Feb 20, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2603 ### Backgound When I set up the Docker container of https://github.com/Mintplex-Labs/anything-llm, and started a conversation, I received the following error: > llama:streaming - could not stream chat. Error: connect ECONNREFUSED 172.17.0.1:11434 although `OLLAMA_BASE_PATH='http://host.docker.internal:11434` was set in the `.env` and `--add-host=host.docker.internal:host-gateway` to docker run command for this to resolve was added. **System:** - Ubuntu Mate 23.10 - current docker image - ollama version is 0.1.20 **Solution**: - [ ] It should be clearer stated that ollama itself has a restriction to localhost and 127.0.0.1 by default and what steps need to be taken to make it work with docker environments. This means that the IP of the Host inside of the virtual docker network does **not bind to port 11434** of the host system by default. It took me several hours to discover and fix this issue. **Steps to fix this:** 1. Edit the service file: Open /etc/systemd/system/ollama.service and add the following line inside the [Service] section: `Environment="OLLAMA_HOST=0.0.0.0"` (the IP can and should of course also be adapted to the respective personal situation, 0.0.0.0 works for all, though.) 2. Once you’ve made your changes, reload the daemons using the command `sudo systemctl daemon-reload` 3. and then restart the service with `sudo systemctl restart ollama`
Author
Owner

@jmorganca commented on GitHub (Feb 20, 2024):

Hi @fukuro-kun, sorry you hit issues with this. The Docker image does bind to 0.0.0.0 by default. Make sure to use the OLLAMA_HOST environment variable if you'd like to customize this. Let me know if you continue to see issues!

<!-- gh-comment-id:1954870528 --> @jmorganca commented on GitHub (Feb 20, 2024): Hi @fukuro-kun, sorry you hit issues with this. The [Docker image](https://github.com/ollama/ollama/blob/main/Dockerfile#L131) does bind to 0.0.0.0 by default. Make sure to use the `OLLAMA_HOST` environment variable if you'd like to customize this. Let me know if you continue to see issues!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#48045