Ollama gives error Connection refused. #155

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

Originally created by @nohYoom on GitHub (Oct 24, 2024).

File "/home/nohyoom/PycharmProjects/PythonProject/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 111] Connection refused

I tried using Windows, but it didn't work and gave me this error, so I tried WSL, but it still doesn't work.

Originally created by @nohYoom on GitHub (Oct 24, 2024). File "/home/nohyoom/PycharmProjects/PythonProject/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: [Errno 111] Connection refused I tried using Windows, but it didn't work and gave me this error, so I tried WSL, but it still doesn't work.
Author
Owner

@Jaswanth-Pillella commented on GitHub (Oct 28, 2024):

Yes, I'm having the same error. I am trying in Google Colab

@Jaswanth-Pillella commented on GitHub (Oct 28, 2024): Yes, I'm having the same error. I am trying in Google Colab
Author
Owner

@ArminFaiom commented on GitHub (Nov 6, 2024):

Did anyone find any solution?

@ArminFaiom commented on GitHub (Nov 6, 2024): Did anyone find any solution?
Author
Owner

@MAXNORM8650 commented on GitHub (Nov 8, 2024):

Same issue: httpx.ConnectError: All connection attempts failed

@MAXNORM8650 commented on GitHub (Nov 8, 2024): Same issue: httpx.ConnectError: All connection attempts failed
Author
Owner

@mchiang0610 commented on GitHub (Nov 15, 2024):

Hey @nohYoom @Jaswanth-Pillella @ArminFaiom @MAXNORM8650 we're trying to get to the bottom of this.

The error message shown doesn't seem like it's running ollama (?). Possible to show us how to reproduce this with Ollama?

@mchiang0610 commented on GitHub (Nov 15, 2024): Hey @nohYoom @Jaswanth-Pillella @ArminFaiom @MAXNORM8650 we're trying to get to the bottom of this. The error message shown doesn't seem like it's running ollama (?). Possible to show us how to reproduce this with Ollama?
Author
Owner

@antoninoLorenzo commented on GitHub (Nov 30, 2024):

@Jaswanth-Pillella how are you running it Google Colab?

@antoninoLorenzo commented on GitHub (Nov 30, 2024): @Jaswanth-Pillella how are you running it Google Colab?
Author
Owner

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

File "/home/nohyoom/PycharmProjects/PythonProject/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: [Errno 111] Connection refused

I tried using Windows, but it didn't work and gave me this error, so I tried WSL, but it still doesn't work.

In Windows 11, running ollama app runs in Windows

If you try to access ollama (assuming that you do a ollama run first) through the pyrthon library in WSL (in my case WSL2), you will get a connection refused because the ip address on which ollama app binds to is different under WSL.

To get the correct ip address , you can use ipconfig to get the ip address associated with Ethernet adapter vEthernet (WSL) and then use

from ollama import ChatResponse, chat, Client

client = Client(
host='http://YOUR_IP_ADDRESS_HERE:11434'
)

response: ChatResponse = client.chat(model='llama3.2:1b', messages=[ {'role': 'user', 'content': 'why is sky blue'} ])

print(response['message']['content'])

@icdev2dev commented on GitHub (Dec 30, 2024): > File "/home/nohyoom/PycharmProjects/PythonProject/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: [Errno 111] Connection refused > > I tried using Windows, but it didn't work and gave me this error, so I tried WSL, but it still doesn't work. In Windows 11, running ollama app runs in Windows If you try to access ollama (assuming that you do a ollama run first) through the pyrthon library in WSL (in my case WSL2), you will get a connection refused because the ip address on which ollama app binds to is different under WSL. To get the correct ip address , you can use ipconfig to get the ip address associated with Ethernet adapter vEthernet (WSL) and then use from ollama import ChatResponse, chat, Client client = Client( host='http://YOUR_IP_ADDRESS_HERE:11434' ) response: ChatResponse = client.chat(model='llama3.2:1b', messages=[ {'role': 'user', 'content': 'why is sky blue'} ]) print(response['message']['content'])
Author
Owner

@Jaswanth-Pillella commented on GitHub (Feb 5, 2025):

@Jaswanth-Pillella how are you running it Google Colab?

Hi sorry for the late response. The error I made was silly, I did not start ollama and tried to use it and also as @icdev2dev mentioned it is good to check which ip did ollama bind.
I think the issue can be closed now.

@Jaswanth-Pillella commented on GitHub (Feb 5, 2025): > [@Jaswanth-Pillella](https://github.com/Jaswanth-Pillella) how are you running it Google Colab? Hi sorry for the late response. The error I made was silly, I did not start ollama and tried to use it and also as @icdev2dev mentioned it is good to check which ip did ollama bind. I think the issue can be closed now.
Author
Owner

@dengyunsheng250 commented on GitHub (Mar 11, 2025):

i meet this error also ,but the solution is useful

@dengyunsheng250 commented on GitHub (Mar 11, 2025): i meet this error also ,but the solution is useful
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#155