[GH-ISSUE #3198] 无法正常请求api,疑似监听地址出错/can't get response properly, may have trouble about binded listenning address #1972

Closed
opened 2026-04-12 12:09:00 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @katfionn on GitHub (Mar 17, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/3198

What is the issue?

我在机器上运行curl测试就可以跑得出结果,局域网另一个电脑就会提示连接被拒绝

在机器上的CURL测试命令:curl http://127.0.0.1:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'
在局域网的CURL测试命令:curl http://192.168.1.3:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'

错误时的提示:
curl: (7) Failed to connect to 192.168.1.3 port 11434 after 0 ms: Couldn't connect to server

机器IP:192.168.1.3
局域网另一个电脑的IP:192.168.1.9
本地网络环境:运行ollama的机器和测试CURL的电脑在同一个局域网,互相能访问


I run curl test on local machine would just worked fine, but i run it on the other machine where is in the same local network, then it just won't work anyway.

command of CURL i used on local machine :
curl http://127.0.0.1:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'

command of CURL i used on the other machine :
curl http://192.168.1.3:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'

IP info ( 192.168.1.1/24)

local machine : 192.168.1.3
the other machine : 192.168.1.9
internal network environment: 192.168.1.1/24

What did you expect to see?

clearly and simple instruction to change the default listenning address for API

详细明确的操作指引,帮我更改我ollama的默认api监听地址

Steps to reproduce

  1. using the curl command to install : curl -fsSL https://ollama.com/install.sh | sh
  2. using command ollama serve to run the service of ollama
  3. using commandd ollama run neural-chat to pull and run a model
  4. test api on local machine, it worked, it's the command: curl http://127.0.0.1:11434/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "neural-chat", "messages": [{"role": "user","content": "Hello!"}]}'
  5. test api on the pc, it won't work anyway, it's the command: curl http://192.168.1.3:11434/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "neural-chat", "messages": [{"role": "user","content": "Hello!"}]}'

Are there any recent changes that introduced the issue?

No response

OS

Linux

Architecture

amd64

Platform

No response

Ollama version

0.1.28

GPU

Nvidia, Other

GPU info

Host machine : RTX2060
local machine is run on the vmware of the host machine

CPU

AMD

Other software

No response

Originally created by @katfionn on GitHub (Mar 17, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/3198 ### What is the issue? 我在机器上运行curl测试就可以跑得出结果,局域网另一个电脑就会提示连接被拒绝 在机器上的CURL测试命令:`curl http://127.0.0.1:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'` 在局域网的CURL测试命令:`curl http://192.168.1.3:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'` 错误时的提示: `curl: (7) Failed to connect to 192.168.1.3 port 11434 after 0 ms: Couldn't connect to server` 机器IP:192.168.1.3 局域网另一个电脑的IP:192.168.1.9 本地网络环境:运行ollama的机器和测试CURL的电脑在同一个局域网,互相能访问 --- I run curl test on local machine would just worked fine, but i run it on the other machine where is in the same local network, then it just won't work anyway. command of CURL i used on local machine : `curl http://127.0.0.1:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'` command of CURL i used on the other machine : `curl http://192.168.1.3:11434/api/generate -d '{"model": "llama2:7b","prompt":"Why is the sky blue?"}'` IP info ( 192.168.1.1/24) local machine : 192.168.1.3 the other machine : 192.168.1.9 internal network environment: 192.168.1.1/24 ### What did you expect to see? clearly and simple instruction to change the default listenning address for API --- 详细明确的操作指引,帮我更改我ollama的默认api监听地址 ### Steps to reproduce 1. using the curl command to install : curl -fsSL https://ollama.com/install.sh | sh 2. using command `ollama serve` to run the service of ollama 3. using commandd `ollama run neural-chat` to pull and run a model 4. test api on local machine, it worked, it's the command: `curl http://127.0.0.1:11434/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "neural-chat", "messages": [{"role": "user","content": "Hello!"}]}'` 5. test api on the pc, it won't work anyway, it's the command: `curl http://192.168.1.3:11434/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "neural-chat", "messages": [{"role": "user","content": "Hello!"}]}'` ### Are there any recent changes that introduced the issue? _No response_ ### OS Linux ### Architecture amd64 ### Platform _No response_ ### Ollama version 0.1.28 ### GPU Nvidia, Other ### GPU info Host machine : RTX2060 local machine is run on the vmware of the host machine ### CPU AMD ### Other software _No response_
GiteaMirror added the bug label 2026-04-12 12:09:00 -05:00
Author
Owner

@mxyng commented on GitHub (Mar 18, 2024):

Binding to 192.168.1.3 does not automatically bind to 127.0.0.1 so this result is expected. If you want to accept connections on multiple addresses, try 0.0.0.0

<!-- gh-comment-id:2003182644 --> @mxyng commented on GitHub (Mar 18, 2024): Binding to 192.168.1.3 does _not_ automatically bind to 127.0.0.1 so this result is expected. If you want to accept connections on multiple addresses, try 0.0.0.0
Author
Owner

@katfionn commented on GitHub (Mar 18, 2024):

Binding to 192.168.1.3 does not automatically bind to 127.0.0.1 so this result is expected. If you want to accept connections on multiple addresses, try 0.0.0.0

Thanks for your reply, but you may not get my point. I know that i should use 0.0.0.0 to be the listening address, but in Linux, there's not instruction or command for me to change it
image

<!-- gh-comment-id:2003193072 --> @katfionn commented on GitHub (Mar 18, 2024): > Binding to 192.168.1.3 does _not_ automatically bind to 127.0.0.1 so this result is expected. If you want to accept connections on multiple addresses, try 0.0.0.0 Thanks for your reply, but you may not get my point. I know that i should use 0.0.0.0 to be the listening address, but in Linux, there's not instruction or command for me to change it ![image](https://github.com/ollama/ollama/assets/136874302/465c4c4e-75e9-4880-b5e8-c6c02ce3baeb)
Author
Owner

@mxyng commented on GitHub (Mar 18, 2024):

Please see the FAQ

<!-- gh-comment-id:2003203019 --> @mxyng commented on GitHub (Mar 18, 2024): Please see the [FAQ](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network)
Author
Owner

@katfionn commented on GitHub (Mar 18, 2024):

Please see the FAQ

OMG, thank you so much, sorry for the trouble

<!-- gh-comment-id:2003206501 --> @katfionn commented on GitHub (Mar 18, 2024): > Please see the [FAQ](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network) OMG, thank you so much, sorry for the trouble
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#1972