[GH-ISSUE #959] [BUG]: Running anything llm container with --network host is hardcoded to give error #583

Closed
opened 2026-02-22 18:20:18 -05:00 by yindo · 1 comment
Owner

Originally created by @ivanskodje on GitHub (Mar 23, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/959

How are you running AnythingLLM?

Docker (local)

What happened?

image

The following docker command is fully functional, and allows me to use localhost rather than a docker internal name to access ollama port since we are setting network to be host when running anythingLLM:

docker run -d -p 3001:3001 --name "anythingllm" \                            
--cap-add SYS_ADMIN --network host \
-v ${STORAGE_LOCATION}:/app/server/storage \
-v ${STORAGE_LOCATION}/.env:/app/server/.env \
-e STORAGE_DIR="/app/server/storage" \
mintplexlabs/anythingllm

However, even though it can connect and even find the models using http://localhost:11434, it seem to be hard-coded to give an error:

Failed to save LLM settings: Localhost, 127.0.0.1, or 0.0.0.0 origins cannot be reached from inside the AnythingLLM container. Please use host.docker.internal, a real machine ip, or domain to connect to your service.

Are there known steps to reproduce?

Run a service such as ollama on your host machine:

# install ollama
curl -fsSL https://ollama.com/install.sh | sh

# run using deepseek-coder
ollama run deepseek-coder

Run anything LLM in a docker container, with network set to host

docker run -d --name "anythingllm" \  
--cap-add SYS_ADMIN --network host \
-v ${STORAGE_LOCATION}:/app/server/storage \
-v ${STORAGE_LOCATION}/.env:/app/server/.env \
-e STORAGE_DIR="/app/server/storage" \
mintplexlabs/anythingllm

In AnythingLLM: Change the LLM url using Ollama to: http://localhost:11434

  • Notice that it can find and load the models just fine

When you press Save changes, a hardcoded error message occurs regardless if you can connect or not.

Suggested Solution

Rather than checking if the URL matches localhost, 127.0.0.1, etc., the first attempt should attempt to load and connect when saving. If saving fails, then, and only then should you check for a localhost/127.0.0.1/etc. match before returning the same error message.

Originally created by @ivanskodje on GitHub (Mar 23, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/959 ### How are you running AnythingLLM? Docker (local) ### What happened? ![image](https://github.com/Mintplex-Labs/anything-llm/assets/6776092/6f93f690-2ae9-4844-8aa2-2b798c973ba5) The following docker command is fully functional, and allows me to use localhost rather than a docker internal name to access ollama port since we are setting network to be host when running anythingLLM: ``` docker run -d -p 3001:3001 --name "anythingllm" \ --cap-add SYS_ADMIN --network host \ -v ${STORAGE_LOCATION}:/app/server/storage \ -v ${STORAGE_LOCATION}/.env:/app/server/.env \ -e STORAGE_DIR="/app/server/storage" \ mintplexlabs/anythingllm ``` However, even though it can connect and even find the models using `http://localhost:11434`, it seem to be hard-coded to give an error: ``` Failed to save LLM settings: Localhost, 127.0.0.1, or 0.0.0.0 origins cannot be reached from inside the AnythingLLM container. Please use host.docker.internal, a real machine ip, or domain to connect to your service. ``` ### Are there known steps to reproduce? Run a service such as ollama on your host machine: ``` # install ollama curl -fsSL https://ollama.com/install.sh | sh # run using deepseek-coder ollama run deepseek-coder ``` Run anything LLM in a docker container, with network set to host ``` docker run -d --name "anythingllm" \ --cap-add SYS_ADMIN --network host \ -v ${STORAGE_LOCATION}:/app/server/storage \ -v ${STORAGE_LOCATION}/.env:/app/server/.env \ -e STORAGE_DIR="/app/server/storage" \ mintplexlabs/anythingllm ``` In AnythingLLM: Change the LLM url using Ollama to: http://localhost:11434 - Notice that it can find and load the models just fine When you press Save changes, a hardcoded error message occurs regardless if you can connect or not. ## Suggested Solution Rather than checking if the URL matches localhost, 127.0.0.1, etc., the first attempt should attempt to load and connect when saving. If saving fails, then, and only then should you check for a localhost/127.0.0.1/etc. match before returning the same error message.
yindo added the enhancementdocumentationDocker labels 2026-02-22 18:20:18 -05:00
yindo closed this issue 2026-02-22 18:20:19 -05:00
Author
Owner

@ivanskodje commented on GitHub (Mar 23, 2024):

I re-tested this by running the master branch of anything LLM locally, and it seem to be working here. However, when I do a breakpoint at the validDockerizedUrl it does not appear to be triggering, which makes me wonder whether or not the test setup skips validations. (It does, however, trigger a breakpoint in customModels.js, so I know breakpoints are working)

I did additional tests locally, it seems if we dont have process.env.ANYTHING_LLM_RUNTIME set to "docker", it will completely skip the test. Which means when this runs in a container, we will completely ignore the --network host change and just show and error regardless. 🐈
This means if you want to reproduce teh issue, you would have to add ANYTHING_LLM_RUNTIME="docker" to the .env.development
file.

@ivanskodje commented on GitHub (Mar 23, 2024): I re-tested this by running the master branch of anything LLM locally, and it seem to be working here. ~However, when I do a breakpoint at the validDockerizedUrl it does not appear to be triggering, which makes me wonder whether or not the test setup skips validations. (It does, however, trigger a breakpoint in customModels.js, so I know breakpoints are working)~ I did additional tests locally, it seems if we dont have `process.env.ANYTHING_LLM_RUNTIME` set to "docker", it will completely skip the test. Which means when this runs in a container, we will completely ignore the --network host change and just show and error regardless. :cat2: This means if you want to reproduce teh issue, you would have to add `ANYTHING_LLM_RUNTIME="docker"` to the `.env.development` file.
yindo changed title from [BUG]: Running anything llm container with --network host is hardcoded to give error to [GH-ISSUE #959] [BUG]: Running anything llm container with --network host is hardcoded to give error 2026-06-05 14:36:08 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#583