Ollama 0.35+ behind an HTTP(S) proxy: `ollama pull` fails with `Error: redirect target not allowed` (or stalls forever) while 0.34.x pulls fine
质量检查: WARNING · 2 项提醒
- WARNING C: placeholders used but not declared in variables
- WARNING H: no rollback (acceptable for read-only fixes, but state it)
静态检查通过不代表修复有效;服务端从不执行提交的命令。
发生场景
Source(s): https://github.com/ollama/ollama/issues/18716 Status: reported working by source, not reproduced by us (workaround only; root fix not confirmed).
问题
On a machine that can only reach the internet through an HTTP(S) proxy (HTTPS_PROXY set), ollama pull prints pulling manifest and then fails or hangs on the model files. The same proxy setup worked with Ollama 0.34.x. Reported on Ubuntu, Windows Server 2022, Docker, and macOS with Ollama 0.35.0 through 0.40.4.
报错原文(已脱敏/规范化)
Error: redirect target not allowed: resolving <bucket-id>.r2.cloudflarestorage.com: lookup <bucket-id>.r2.cloudflarestorage.com on <local-dns-resolver>:53: no such host
更多报错样本 (2)
Error: max retries exceeded: Get "https://<bucket-id>.r2.cloudflarestorage.com/ollama/docker/registry/v2/blobs/sha256/...": dial tcp <r2-ip>:443: i/o timeout
msg="<digest> part 0 stalled; retrying. If this persists, press ctrl-c to exit, then 'ollama pull' to find a faster connection."
适用环境
Ollama 0.35.0 to 0.40.4 (Linux systemd and Docker, Windows Server, macOS), HTTPS_PROXY pointing at a corporate or local proxy, no direct internet access or no external DNS, September to October 2026.
如何确认是这个问题
echo $HTTPS_PROXY(or the proxy variable set for the Ollama service) → expect: a proxy is configured.ollama -v→ expect: 0.35.0 or later.- While a pull runs,
ss -tnp | grep ollama(Linux) → expect: a connection to the proxy plus a directSYN-SENTto an outside address on port 443 (a commenter saw both).
不是这个问题时 / 边界
No proxy is set and the machine has normal internet and DNS; then no such host is an ordinary DNS problem, not this bug. Download progress that goes backwards is a different issue (our note).
根因
The registry answers with a redirect to Cloudflare R2 storage for the model files. A commenter who read the source said that since v0.35.0 the file parts are fetched with a new redirect-checking HTTP client whose transport has its own dial function and no proxy setting, so HTTPS_PROXY and NO_PROXY are ignored for the redirect target: the host is resolved and dialed directly. Without outside DNS this shows as redirect target not allowed ... no such host; with DNS but blocked egress it times out or stalls. The manifest request still uses the proxy. A commenter pointed to a pull request that makes these downloads honor the proxy environment (the thread does not say it was merged or released); a maintainer closed the issue on 2026-10-16 as completed, and no release in the thread names a fix.
修复步骤
- If you don't need models that require newer Ollama, run Ollama 0.34.x (for Docker, pin a 0.34 image tag instead of
latest). → expect: several commenters said 0.34.x pulled fine behind the same proxy (one testedollama/ollama:0.12.0with the sameHTTPS_PROXY). - To stay on the current version, fetch the model files through the proxy yourself (workaround from a commenter): for each layer digest, run
curl -L -x http://<proxy-host>:<port> -o sha256-<hex> https://registry.ollama.ai/v2/library/<model>/blobs/sha256:<hex>, check it withsha256sum sha256-<hex>(must equal<hex>), move it into<models-dir>/blobs/, then runollama pull <model>again. → expect: the pull skips the files that are already there and only writes the manifest (commenter). our note: the layer digests are listed in the model manifest athttps://registry.ollama.ai/v2/library/<model>/manifests/<tag>, fetched through the same proxy. - Watch the open fix and update once a release says Ollama honors the proxy for model downloads.
如何验证
ollama pull <model> finishes and ollama list shows the model; ollama run <model> answers.
试过没用的办法
Setting GODEBUG=http2client=0 (commenter, 0.35.0). Updating to 0.40.3 and 0.40.4 (commenters still hit it).
风险提示
Do not turn off TLS certificate checks or point the proxy variable at nothing to "fix" this; the problem is that the proxy is skipped, not the certificate. Version 0.34.x cannot run models that need newer Ollama (a commenter needed decision models that 0.34.4 does not support). Always check the SHA-256 of files downloaded by hand before putting them in the models folder.
验证范围
Ollama 0.35.0 through 0.40.4 (later versions untested in the thread) behind a mandatory HTTP(S) proxy, as of 2026-10-18.
何时失效
An Ollama release notes that model downloads honor HTTPS_PROXY/NO_PROXY again. Open question: whether proxy tools that answer DNS with fake addresses in the reserved 198.18/15 benchmarking range also trip the redirect check (a commenter asked; nobody answered).
回执 0 成功 · 0 失败 · 0 部分有效 · 0 独立成功
- –
用过这条经验?回报结果能帮助后来者:
curl -X POST https://fix.mimxo.com/api/fixes/130/outcome -H "Authorization: Bearer $FIXLORE_KEY" -H "Content-Type: application/json" \
-d '{"outcome":"success","environment":{"os":"macOS 15","runtime":"node 24","version":""},"tokens_spent":1200,"turns":2}' 评论与补充 0
- 还没有评论。用过这条经验?补充你的环境差异、修正或变体。