Simple Chat gives httpx.ConnectError #191

Open
opened 2026-02-15 16:28:35 -05:00 by yindo · 4 comments
Owner

Originally created by @designcomputer on GitHub (Dec 29, 2024).

This simple chat example fails:

from ollama import chat

messages = [
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
]

response = chat('llama3.2:3b', messages=messages)
print(response['message']['content'])

httpx.ConnectError: [WinError 10049] The requested address is not valid in its context

But this works fine:

from ollama import Client
client = Client(
  host='http://localhost:11434',
  headers={'x-some-header': 'some-value'}
)
response = client.chat(model='llama3.2:3b', messages=[
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
])

print(response['message']['content'])
# or access fields directly from the response object
print(response.message.content)

The sky appears blue because of a phenomenon called scattering, which occurs when sunlight interacts with the tiny molecules of gases in the Earth's atmosphere.....

Originally created by @designcomputer on GitHub (Dec 29, 2024). This simple chat example fails: ``` from ollama import chat messages = [ { 'role': 'user', 'content': 'Why is the sky blue?', }, ] response = chat('llama3.2:3b', messages=messages) print(response['message']['content']) ``` **httpx.ConnectError: [WinError 10049] The requested address is not valid in its context** But this works fine: ``` from ollama import Client client = Client( host='http://localhost:11434', headers={'x-some-header': 'some-value'} ) response = client.chat(model='llama3.2:3b', messages=[ { 'role': 'user', 'content': 'Why is the sky blue?', }, ]) print(response['message']['content']) # or access fields directly from the response object print(response.message.content) ``` **The sky appears blue because of a phenomenon called scattering, which occurs when sunlight interacts with the tiny molecules of gases in the Earth's atmosphere.....**
Author
Owner

@ParthSareen commented on GitHub (Dec 29, 2024):

Hi @designcomputer! Possible this is some kind of firewall issue - is this on windows?

@ParthSareen commented on GitHub (Dec 29, 2024): Hi @designcomputer! Possible this is some kind of firewall issue - is this on windows?
Author
Owner

@designcomputer commented on GitHub (Dec 29, 2024):

Hi @designcomputer! Possible this is some kind of firewall issue - is this on windows?

Yes, I am using a Windows computer, as indicated by the error message. Assuming the chat function defaults to http://localhost:11434 when the host is not explicitly defined, I’m curious why explicitly defining the host resolves the issue. Could this point to something specific about how the chat function currently handles the default host configuration? The failing example obviously worked in the past.

@designcomputer commented on GitHub (Dec 29, 2024): > Hi @designcomputer! Possible this is some kind of firewall issue - is this on windows? Yes, I am using a Windows computer, as indicated by the error message. Assuming the chat function defaults to http://localhost:11434 when the host is not explicitly defined, I’m curious why explicitly defining the host resolves the issue. Could this point to something specific about how the chat function currently handles the default host configuration? The failing example obviously worked in the past.
Author
Owner

@ParthSareen commented on GitHub (Dec 29, 2024):

Did you have a version at which point this was working? Wondering if this is more so windows related or library related. Don't think there have been any client changes in a while

@ParthSareen commented on GitHub (Dec 29, 2024): Did you have a version at which point this was working? Wondering if this is more so windows related or library related. Don't think there have been any client changes in a while
Author
Owner

@designcomputer commented on GitHub (Dec 30, 2024):

Did you have a version at which point this was working? Wondering if this is more so windows related or library related. Don't think there have been any client changes in a while

I believe it used to function properly. The issue might stem from an update made to httpx or related dependencies.

@designcomputer commented on GitHub (Dec 30, 2024): > Did you have a version at which point this was working? Wondering if this is more so windows related or library related. Don't think there have been any client changes in a while I believe it used to function properly. The issue might stem from an update made to httpx or related dependencies.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#191