nilsherzig / LLocalSearch

LLocalSearch is a completely locally running search aggregator using LLM Agents. The user can ask a question and the system will use a chain of LLMs to find the answer. The user can see the progress of the agents and the final answer. No OpenAI or Google API keys are needed.
Apache License 2.0
5.58k stars 352 forks source link

http://127.0.0.1:11434/api/pull: dial tcp 127.0.0.1:11434: connect: connection refused #9

Open digimonster opened 5 months ago

digimonster commented 5 months ago

Hi, I followed the tutorial to start this project locally, but I'm unable to access the local ollama service. I want to know how to resolve this issue. Here is my error message:

My local env:

os:MacBook Pro M1 Pro 14.2.1 ollama version is 0.1.29 python: 3.11

docker-compose.dev.yaml

image

Error Info:

image image

ollama pull api test

image
nilsherzig commented 5 months ago

The backend (the price of code which tries to connect to ollama) runs inside a docker container.

A docker container is like a small virtual computer. This virtual computer has its own networking. Connecting to localhost from inside the container will connect to the localhost of the container, not your MacBooks localhost.

I have to find the IP of your MacBook and connect to it, not the containers localhost.

nilsherzig commented 5 months ago

Sadly, there isn't a universal working solution for this (that I know of). MacOS and Windows run docker inside a real virtual machine, which makes it hard to set a sensible default for the Ollama connection.

nilsherzig commented 5 months ago

Try this:

docker exec -it localsearchui-backend-dev-1 ip r

image

The ip in red should be your hosts ip (inside the docker network). On linux this would allow you to connect to it. Im not sure about MacOS, since containers run in vms.

cybervinit commented 5 months ago

I was able to solve this on MacOS by adding

    extra_hosts:
      - "host.docker.internal:host-gateway"

inside my docker-compose.yaml file backend config and then setting - OLLAMA_HOST=http://host.docker.internal:11434 inside environments. This gives access for processes running inside a docker container to the host services running outside the container.

nilsherzig commented 5 months ago

I was able to solve this on MacOS by adding

    extra_hosts:
      - "host.docker.internal:host-gateway"

inside my docker-compose.yaml file backend config and then setting - OLLAMA_HOST=http://host.docker.internal:11434 inside environments. This gives access for processes running inside a docker container to the host services running outside the container.

oh, this works on macOS? i though not, because macOS is running docker inside a vm. Thanks for checking :)

andrewgy8 commented 5 months ago

FWIW, on mac I was able to add

- OLLAMA_HOST=http://host.docker.internal:11434

To get it to work.

0ofta commented 5 months ago

I apologise if there is a better way to communicate this, than reopening this issue, but I got the exact same problem, cloning the master today.

After some searching, I figured out that for host.docker.internal to work on Linux (or at least my Arch Linux install), docker desktop had to be installed.

It took me quite some time to figure out, so I wanted to share, in case others have the same trouble. Maybe this could be put in the readme.md.

Thanks for your amazing work!

nilsherzig commented 5 months ago

Docker Desktop as in the GUI application? Works on my dev machine (NixOS) and my test server (ubuntu 22.04) without it

still good to know, thanks. i think i will rework the networking thing to make it less "best practice" and more usable haha

0ofta commented 5 months ago

Yes, as in the desktop application. it also needs to be started, for it to work, so it does not seem to be -only- a dependency issue, either ¯(°_o)/¯ weird

This was a test on my laptop on cpu, which was pretty useless (way too slow), so I will try to get it working on my desktop now - will let you know if I find the root cause for my trouble, and if it is consistant across my Arch devices.

I can also fire up a fresh Arch out-of-the-box VM with gnome, so we know it's not my setup or WM being difficult :)

I will let you know my findings.

0ofta commented 5 months ago

I have done the same steps on my Arch desktop, as well as a fresh VM install of Arch, gnome, ollama and docker - with the same behaviour on all computers. Without docker-desktop, I get connection refused, even when setting host IP directly in docker-compose.yaml.

As this seems to be arch rooted, I see no reason for you to give this much more though, as it is working on other distros. But I will let you know, if I find a less crazy solution than installing a gig of desktop-app, haha

again, thanks for you great work - much obliged!

nilsherzig commented 5 months ago

Yea i guess i will go with a more simplistic networking setup. People who need something more complex will build something fitting for themselves anyway

nilsherzig commented 5 months ago

thanks for reporting

nilsherzig commented 5 months ago

Depends on #21 tho haha, vite ignores my attempts to set values using env vars haha

yugarinn commented 5 months ago

I am experiencing this issue on my Fedora 39 machine as well. Here's my setup:

OS: Fedora 39
Docker Engine: 26.0.1
Docker Compose: v2.26.1
Ollama: 0.1.30

I'll continue debugging this and post my findings here if I discover a solution.

Thanks for all the hard work; this project is amazing!