Why can't I call the local Ollama model through this python library under Windows system? #225

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

Originally created by @S0RA27 on GitHub (Feb 21, 2025).

Why can't I call the local Ollama model through this python library under Windows system?
this is my code:

import numpy as np
from ollama import chat, Message
import ollama

message = [
Message(role='system', content='translate zh-cn'),
Message(role='user', content='good night')
]

response = chat(model='llama3.2',messages=message)
print(response)

here is my error:
Exception has occurred: RemoteProtocolError
Server disconnected without sending a response.
httpcore.RemoteProtocolError: Server disconnected without sending a response.

The above exception was the direct cause of the following exception:

File "C:\Users\38231\Desktop\RAG\RAG_Chat.py", line 11, in
response = chat(model='llama3.2',messages=message)
httpx.RemoteProtocolError: Server disconnected without sending a response.

Originally created by @S0RA27 on GitHub (Feb 21, 2025). Why can't I call the local Ollama model through this python library under Windows system? this is my code: import numpy as np from ollama import chat, Message import ollama message = [ Message(role='system', content='translate zh-cn'), Message(role='user', content='good night') ] response = chat(model='llama3.2',messages=message) print(response) here is my error: Exception has occurred: RemoteProtocolError Server disconnected without sending a response. httpcore.RemoteProtocolError: Server disconnected without sending a response. The above exception was the direct cause of the following exception: File "C:\Users\38231\Desktop\RAG\RAG_Chat.py", line 11, in <module> response = chat(model='llama3.2',messages=message) httpx.RemoteProtocolError: Server disconnected without sending a response.
yindo closed this issue 2026-02-15 16:28:52 -05:00
Author
Owner

@ParthSareen commented on GitHub (Feb 21, 2025):

Can you verify you're able to run ollama through the terminal with ollama run llama3.2

@ParthSareen commented on GitHub (Feb 21, 2025): Can you verify you're able to run ollama through the terminal with `ollama run llama3.2`
Author
Owner

@xuzexin-hz commented on GitHub (Mar 5, 2025):

So you can debug and see what URL is being accessed? Or confirm the OLLAMA_HOST system variable. The most effective way is to debug

@xuzexin-hz commented on GitHub (Mar 5, 2025): So you can debug and see what URL is being accessed? Or confirm the OLLAMA_HOST system variable. The most effective way is to debug
Author
Owner

@lemassykoi commented on GitHub (Mar 5, 2025):

Why can't I call the local Ollama model through this python library under Windows system? this is my code:

import numpy as np from ollama import chat, Message import ollama

message = [ Message(role='system', content='translate zh-cn'), Message(role='user', content='good night') ]

response = chat(model='llama3.2',messages=message) print(response)

here is my error: Exception has occurred: RemoteProtocolError Server disconnected without sending a response. httpcore.RemoteProtocolError: Server disconnected without sending a response.

The above exception was the direct cause of the following exception:

File "C:\Users\38231\Desktop\RAG\RAG_Chat.py", line 11, in response = chat(model='llama3.2',messages=message) httpx.RemoteProtocolError: Server disconnected without sending a response.

add this to your script:

import os
os.environ['OLLAMA_HOST'] = 'http://127.0.0.1:11434'
@lemassykoi commented on GitHub (Mar 5, 2025): > Why can't I call the local Ollama model through this python library under Windows system? this is my code: > > import numpy as np from ollama import chat, Message import ollama > > message = [ Message(role='system', content='translate zh-cn'), Message(role='user', content='good night') ] > > response = chat(model='llama3.2',messages=message) print(response) > > here is my error: Exception has occurred: RemoteProtocolError Server disconnected without sending a response. httpcore.RemoteProtocolError: Server disconnected without sending a response. > > The above exception was the direct cause of the following exception: > > File "C:\Users\38231\Desktop\RAG\RAG_Chat.py", line 11, in response = chat(model='llama3.2',messages=message) httpx.RemoteProtocolError: Server disconnected without sending a response. add this to your script: ```python import os os.environ['OLLAMA_HOST'] = 'http://127.0.0.1:11434' ```
Author
Owner

@ParthSareen commented on GitHub (Apr 9, 2025):

OLLAMA_HOST should not be 0.0.0.0 from the client side.

https://github.com/ollama/ollama-python/pull/491#issuecomment-2790636938

@ParthSareen commented on GitHub (Apr 9, 2025): `OLLAMA_HOST` should not be `0.0.0.0` from the client side. https://github.com/ollama/ollama-python/pull/491#issuecomment-2790636938
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#225