[GH-ISSUE #8304] Unable to bind 0.0.0.0 port to all interfaces, except localhost #5317

Closed
opened 2026-04-12 16:30:43 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @drigio on GitHub (Jan 4, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8304

What is the issue?

I'm trying to ollama serve by setting env variable OLLAMA_HOST=0.0.0.0 on windows. However I am only able to access it via localhost:11434. Unable to access it via my host ip, nor via 127.0.0.1.
There is no proxy enabled, no vpn.
I have disabled firewall in my windows machine.

ollama serve logs

2025/01/04 00:19:16 routes.go:1259: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://0.0.0.0:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_KV_CACHE_TYPE: OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:C:\\<REDACTED>\\.ollama\\models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://* vscode-webview://*] OLLAMA_SCHED_SPREAD:false ROCR_VISIBLE_DEVICES:]"
time=2025-01-04T00:19:16.089-08:00 level=INFO source=images.go:757 msg="total blobs: 9"
time=2025-01-04T00:19:16.090-08:00 level=INFO source=images.go:764 msg="total unused blobs removed: 0"
time=2025-01-04T00:19:16.091-08:00 level=INFO source=routes.go:1310 msg="Listening on [::]:11434 (version 0.5.4)"
time=2025-01-04T00:19:16.091-08:00 level=INFO source=routes.go:1339 msg="Dynamic LLM libraries" runners="[cuda_v11_avx cuda_v12_avx rocm_avx cpu cpu_avx cpu_avx2]"
time=2025-01-04T00:19:16.091-08:00 level=INFO source=gpu.go:226 msg="looking for compatible GPUs"
time=2025-01-04T00:19:16.091-08:00 level=INFO source=gpu_windows.go:167 msg=packages count=1
time=2025-01-04T00:19:16.092-08:00 level=INFO source=gpu_windows.go:183 msg="efficiency cores detected" maxEfficiencyClass=1
time=2025-01-04T00:19:16.092-08:00 level=INFO source=gpu_windows.go:214 msg="" package=0 cores=10 efficiency=4 threads=16

ollama list logs

ollama list
Error: Head "http://0.0.0.0:11434/": read tcp 127.0.0.1:65461->127.0.0.1:11434: wsarecv: An existing connection was forcibly closed by the remote host.

$env:OLLAMA_HOST = "localhost"; ollama list
NAME                         ID              SIZE      MODIFIED
nomic-embed-text:latest      0a109f422b47    274 MB    About an hour ago
llama3.1:8b-instruct-q8_0    b158ded76fa0    8.5 GB    6 hours ago

$env:OLLAMA_HOST = "HOST_IP"; ollama list
Error: Head "http://HOST_IP:11434/": read tcp HOST_IP:65470->HOST_IP:11434: wsarecv: An existing connection was forcibly closed by the remote host.

Can someone please help on this? I am not running WSL.

OS

Windows

GPU

Nvidia

CPU

Intel

Ollama version

0.5.4

Originally created by @drigio on GitHub (Jan 4, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8304 ### What is the issue? I'm trying to `ollama serve` by setting env variable `OLLAMA_HOST=0.0.0.0` on windows. However I am only able to access it via localhost:11434. Unable to access it via my host ip, nor via 127.0.0.1. There is no proxy enabled, no vpn. I have disabled firewall in my windows machine. ollama serve logs ``` 2025/01/04 00:19:16 routes.go:1259: INFO server config env="map[CUDA_VISIBLE_DEVICES: GPU_DEVICE_ORDINAL: HIP_VISIBLE_DEVICES: HSA_OVERRIDE_GFX_VERSION: HTTPS_PROXY: HTTP_PROXY: NO_PROXY: OLLAMA_DEBUG:false OLLAMA_FLASH_ATTENTION:false OLLAMA_GPU_OVERHEAD:0 OLLAMA_HOST:http://0.0.0.0:11434 OLLAMA_INTEL_GPU:false OLLAMA_KEEP_ALIVE:5m0s OLLAMA_KV_CACHE_TYPE: OLLAMA_LLM_LIBRARY: OLLAMA_LOAD_TIMEOUT:5m0s OLLAMA_MAX_LOADED_MODELS:0 OLLAMA_MAX_QUEUE:512 OLLAMA_MODELS:C:\\<REDACTED>\\.ollama\\models OLLAMA_MULTIUSER_CACHE:false OLLAMA_NOHISTORY:false OLLAMA_NOPRUNE:false OLLAMA_NUM_PARALLEL:0 OLLAMA_ORIGINS:[http://localhost https://localhost http://localhost:* https://localhost:* http://127.0.0.1 https://127.0.0.1 http://127.0.0.1:* https://127.0.0.1:* http://0.0.0.0 https://0.0.0.0 http://0.0.0.0:* https://0.0.0.0:* app://* file://* tauri://* vscode-webview://*] OLLAMA_SCHED_SPREAD:false ROCR_VISIBLE_DEVICES:]" time=2025-01-04T00:19:16.089-08:00 level=INFO source=images.go:757 msg="total blobs: 9" time=2025-01-04T00:19:16.090-08:00 level=INFO source=images.go:764 msg="total unused blobs removed: 0" time=2025-01-04T00:19:16.091-08:00 level=INFO source=routes.go:1310 msg="Listening on [::]:11434 (version 0.5.4)" time=2025-01-04T00:19:16.091-08:00 level=INFO source=routes.go:1339 msg="Dynamic LLM libraries" runners="[cuda_v11_avx cuda_v12_avx rocm_avx cpu cpu_avx cpu_avx2]" time=2025-01-04T00:19:16.091-08:00 level=INFO source=gpu.go:226 msg="looking for compatible GPUs" time=2025-01-04T00:19:16.091-08:00 level=INFO source=gpu_windows.go:167 msg=packages count=1 time=2025-01-04T00:19:16.092-08:00 level=INFO source=gpu_windows.go:183 msg="efficiency cores detected" maxEfficiencyClass=1 time=2025-01-04T00:19:16.092-08:00 level=INFO source=gpu_windows.go:214 msg="" package=0 cores=10 efficiency=4 threads=16 ``` ollama list logs ``` ollama list Error: Head "http://0.0.0.0:11434/": read tcp 127.0.0.1:65461->127.0.0.1:11434: wsarecv: An existing connection was forcibly closed by the remote host. $env:OLLAMA_HOST = "localhost"; ollama list NAME ID SIZE MODIFIED nomic-embed-text:latest 0a109f422b47 274 MB About an hour ago llama3.1:8b-instruct-q8_0 b158ded76fa0 8.5 GB 6 hours ago $env:OLLAMA_HOST = "HOST_IP"; ollama list Error: Head "http://HOST_IP:11434/": read tcp HOST_IP:65470->HOST_IP:11434: wsarecv: An existing connection was forcibly closed by the remote host. ``` Can someone please help on this? I am not running WSL. ### OS Windows ### GPU Nvidia ### CPU Intel ### Ollama version 0.5.4
GiteaMirror added the bug label 2026-04-12 16:30:43 -05:00
Author
Owner

@rick-github commented on GitHub (Jan 4, 2025):

Are you running an IPv6 stack on your machine? What does netstat -ano | findstr 11434 show? What about ping localhost and ping %COMPUTERNAME%?

<!-- gh-comment-id:2571285135 --> @rick-github commented on GitHub (Jan 4, 2025): Are you running an IPv6 stack on your machine? What does `netstat -ano | findstr 11434` show? What about `ping localhost` and `ping %COMPUTERNAME%`?
Author
Owner

@drigio commented on GitHub (Jan 5, 2025):

Thank you @rick-github for getting back!

What does netstat -ano | findstr 11434 show?

netstat -ano | findstr 11434
TCP    0.0.0.0:11434          0.0.0.0:0              LISTENING       21232

Are you running an IPv6 stack on your machine?

Yes

What about ping localhost and ping %COMPUTERNAME%?

 ping localhost

Pinging <PC_NAME> [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

ping %COMPUTERNAME%
Ping request could not find host %COMPUTERNAME%. Please check the name and try again.

I don't think I have an env variable in my user or system with COMPUTERNAME.

<!-- gh-comment-id:2571446871 --> @drigio commented on GitHub (Jan 5, 2025): Thank you @rick-github for getting back! > What does netstat -ano | findstr 11434 show? ```bash netstat -ano | findstr 11434 TCP 0.0.0.0:11434 0.0.0.0:0 LISTENING 21232 ``` > Are you running an IPv6 stack on your machine? Yes >What about ping localhost and ping %COMPUTERNAME%? ```bash ping localhost Pinging <PC_NAME> [::1] with 32 bytes of data: Reply from ::1: time<1ms Reply from ::1: time<1ms Reply from ::1: time<1ms Reply from ::1: time<1ms Ping statistics for ::1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms ping %COMPUTERNAME% Ping request could not find host %COMPUTERNAME%. Please check the name and try again. ``` I don't think I have an env variable in my user or system with COMPUTERNAME.
Author
Owner

@rick-github commented on GitHub (Jan 5, 2025):

Didn't notice you were using PS: what does ping $env:COMPUTERNAME return?

From the log, ollama is binding to the IPv6 address, which in most network stacks also accepts connections in the corresponding IPv4 address, and the netstat output certainly make it looks like this the case. But it seems like IPv4 addresses are not working as show by your connection failures. Presumably if you set $env:OLLAMA_HOST = "[::1]" then it will work, and similarly if you use the IPv6 address of your machine (from ping $env:COMPUTERNAME) then clients on the LAN will be able to connect. But I'm afraid Windows networking is outside my wheelhouse, somebody else will have to dig in to this.

<!-- gh-comment-id:2571458687 --> @rick-github commented on GitHub (Jan 5, 2025): Didn't notice you were using PS: what does `ping $env:COMPUTERNAME` return? From the log, ollama is binding to the IPv6 address, which in most network stacks also accepts connections in the corresponding IPv4 address, and the `netstat` output certainly make it looks like this the case. But it seems like IPv4 addresses are not working as show by your connection failures. Presumably if you set `$env:OLLAMA_HOST = "[::1]"` then it will work, and similarly if you use the IPv6 address of your machine (from `ping $env:COMPUTERNAME`) then clients on the LAN will be able to connect. But I'm afraid Windows networking is outside my wheelhouse, somebody else will have to dig in to this.
Author
Owner

@drigio commented on GitHub (Jan 5, 2025):

ping $env:COMPUTERNAME

Pinging <PC NAME> [IP_V6_ADDRESS] with 32 bytes of data:
Reply from IP_V6_ADDRESS: time<1ms
Reply from IP_V6_ADDRESS: time<1ms
Reply from IP_V6_ADDRESS: time<1ms
Reply from IP_V6_ADDRESS: time<1ms

Ping statistics for IP_V6_ADDRESS:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

if you use the IPv6 address of your machine (from ping $env:COMPUTERNAME) then clients on the LAN will be able to connect.

You're right ! Thank you for pointing that out. I will try disabling the IPV6 stack and check if the behavior is as expected. I am also very unsure about Windows networking.

Will update here shortly!

<!-- gh-comment-id:2571464370 --> @drigio commented on GitHub (Jan 5, 2025): ```bash ping $env:COMPUTERNAME Pinging <PC NAME> [IP_V6_ADDRESS] with 32 bytes of data: Reply from IP_V6_ADDRESS: time<1ms Reply from IP_V6_ADDRESS: time<1ms Reply from IP_V6_ADDRESS: time<1ms Reply from IP_V6_ADDRESS: time<1ms Ping statistics for IP_V6_ADDRESS: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms ``` > if you use the IPv6 address of your machine (from ping $env:COMPUTERNAME) then clients on the LAN will be able to connect. You're right ! Thank you for pointing that out. I will try disabling the IPV6 stack and check if the behavior is as expected. I am also very unsure about Windows networking. Will update here shortly!
Author
Owner

@drigio commented on GitHub (Jan 6, 2025):

Update

And now even if its listening on ::11434, it is able to bind to ipv4 n/w interfaces. 🥳

According to this it should listen to all both ipv4 and ipv6 addresses, but somehow on my machine only bound to ipv6.
I don't know why it didnt work earlier, but if it's a reasonable request for the devs, I would love to see a flag / env variable to force fallback to ipv4 stack to bind to in ollama.

Thanks @rick-github for your help! Let me know if I should create a new issue for the request or change the title for this issue. If not would close this issue.

<!-- gh-comment-id:2572382180 --> @drigio commented on GitHub (Jan 6, 2025): ## Update - I disabled ipv6 for all networks using below command : `Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6` - I disabled ipv6 from Windows Registry by adding a new key to `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\` as documented here -> https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows - Rebooted machine And now even if its listening on ::11434, it is able to bind to ipv4 n/w interfaces. 🥳 According to [this](https://pkg.go.dev/net#:~:text=For%20TCP%20networks%2C%20if%20the%20host%20in%20the%20address%20parameter%20is%20empty%20or%20a%20literal%20unspecified%20IP%20address%2C%20Listen%20listens%20on%20all%20available%20unicast%20and%20anycast%20IP%20addresses%20of%20the%20local%20system.%20To%20only%20use%20IPv4%2C%20use%20network%20%22tcp4%22.) it should listen to all both ipv4 and ipv6 addresses, but somehow on my machine only bound to ipv6. I don't know why it didnt work earlier, but if it's a reasonable request for the devs, I would love to see a `flag / env variable` to force fallback to ipv4 stack to bind to in ollama. Thanks @rick-github for your help! Let me know if I should create a new issue for the request or change the title for this issue. If not would close this issue.
Author
Owner

@pgiki commented on GitHub (Jan 9, 2025):

I also faced similar issue when I wanted to call ollama on a model running on docker container. I solved it by running OLLAMA_HOST=http://0.0.0.0:11434 ollama serve. I am using macOS so you might need to change the command above to work on WIndows too.

<!-- gh-comment-id:2580463531 --> @pgiki commented on GitHub (Jan 9, 2025): I also faced similar issue when I wanted to call ollama on a model running on docker container. I solved it by running `OLLAMA_HOST=http://0.0.0.0:11434 ollama serve`. I am using macOS so you might need to change the command above to work on WIndows too.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5317