fix(providers): use 127.0.0.1 instead of localhost for local LLM URLs#3112
Merged
Conversation
On dual-stack hosts (notably macOS), `localhost` resolves to both ::1 and 127.0.0.1 with IPv6 tried first. Local LLM servers (Ollama, vLLM, LM Studio, Lemonade) typically bind IPv4 only, so the IPv6 attempt returns connection-refused immediately and Happy Eyeballs fallback isn't reliably triggered — leading to spurious "Configured local provider offline" warnings even when the server is running and reachable via curl. Changes the hardcoded fallback URLs in PROVIDER_REGISTRY, embedding driver fallback, kernel auto-detect injection, the ollama detect route, and the init config template comments. Note: the user-facing TOML in `~/.librefang/registry/providers/*.toml` comes from the separate librefang-registry repo and needs a matching PR there to fully eliminate the warnings on existing installs.
houko
added a commit
to librefang/librefang-registry
that referenced
this pull request
Apr 25, 2026
…73) On dual-stack hosts (notably macOS), `localhost` resolves to both ::1 and 127.0.0.1 with IPv6 tried first. Local LLM servers (Ollama, vLLM, LM Studio) installed via the standard scripts bind IPv4 only, so the IPv6 connection attempt fails immediately and Happy Eyeballs fallback to IPv4 isn't reliably triggered for connection-refused errors, producing spurious "Configured local provider offline" warnings in the daemon even when the server is up and reachable via curl. Companion to librefang/librefang#3112 which fixes the hardcoded URL constants in the main repo. After both land, existing installs pick up the fix on their next registry sync.
2 tasks
houko
added a commit
that referenced
this pull request
Apr 25, 2026
…ault change (#3118) PR #3112 changed the local provider defaults from `http://localhost:` to `http://127.0.0.1:` in PROVIDER_REGISTRY but didn't update the two test assertions that pinned the old default. Main has been red since that landed: FAIL model_catalog::tests::test_apply_url_overrides left: "http://127.0.0.1:1234/v1" right: "http://localhost:1234/v1" FAIL model_catalog::tests::test_set_provider_url left: "http://127.0.0.1:11434/v1" right: "http://localhost:11434/v1" Update the two assertions. test_set_provider_url_unknown still uses `localhost:9999` because it's exercising user-supplied URL passthrough (not the default), unrelated to #3112.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On dual-stack hosts (notably macOS),
localhostresolves to both::1and127.0.0.1with IPv6 tried first. Local LLM servers (Ollama / vLLM / LM Studio / Lemonade) installed via the standard scripts bind IPv4 only, so reqwest's first connection attempt to[::1]:<port>is refused instantly. Happy Eyeballs fallback to IPv4 isn't reliably triggered for connection-refused (vs. timeout), so the probe fails outright and the daemon spams:…even though
curl http://localhost:11434/api/tagsworks fine (curl explicitly does the IPv6→IPv4 fallback).Repro
$ lsof -iTCP:11434 -sTCP:LISTEN COMMAND PID USER FD TYPE NODE NAME ollama ... ... 5u IPv4 TCP localhost:11434 (LISTEN) ← IPv4 only $ cat /etc/hosts | grep localhost 127.0.0.1 localhost ::1 localhostThe TCP-level reachability check at
kernel/mod.rs:1754already uses127.0.0.1directly (and succeeds), but the URL stored inprovider_urls.ollamawashttp://localhost:11434/v1, so subsequent reqwest calls fail. This PR brings the URL strings in line with the reachability check.Changes
Production code:
PROVIDER_REGISTRYdefaults forollama,vllm,lmstudio,lemonade(librefang-llm-drivers)librefang-runtime/embedding.rs)provider_urls(librefang-kernel/kernel/mod.rs)librefang-api/routes/providers.rs::detect_ollama)librefang-cli/templates/init_default_config.toml)Existing test fixtures that happen to use
localhostas an arbitrary input string are intentionally left alone (they're not asserting the default URL constant). The twomodel_catalog.rstests that DO assert default URLs (test_set_provider_url,test_apply_url_overrides) still load from the livelibrefang-registryrepo viaresolve_home_dir_for_tests, so they are not affected by this PR — they will need updating in tandem with the registry-repo PR (see below).Follow-up needed
The runtime probe URL (the one that actually triggered the warning the user reported) comes from
~/.librefang/registry/providers/ollama.toml, which is synced from thelibrefang-registryrepo. A matching PR is needed there to flip thosebase_urlfields fromhttp://localhost:...tohttp://127.0.0.1:.... After both land, existing installs will pick up the fix on their next registry sync.Test plan
provider_urls.ollamaoverride inconfig.toml: start daemon, confirm noConfigured local provider offlinewarning and ollama appears as reachable in the model catalog