Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Ollama not binding to 0.0.0.0 #3581

Closed
kellerkind84 opened this issue Apr 10, 2024 · 16 comments
Closed

MacOS Ollama not binding to 0.0.0.0 #3581

kellerkind84 opened this issue Apr 10, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@kellerkind84
Copy link

What is the issue?

So when set the OLLAMA_HOST to 0.0.0.0, I cannot access Ollama via the IP, but I can still access it via localhost.

What did you expect to see?

I expect it to be available under :11434

Steps to reproduce

No response

Are there any recent changes that introduced the issue?

No response

OS

macOS

Architecture

arm64

Platform

No response

Ollama version

0.1.31

GPU

Apple

GPU info

No response

CPU

Apple

Other software

No response

@kellerkind84 kellerkind84 added bug Something isn't working needs-triage labels Apr 10, 2024
@dims
Copy link

dims commented Apr 11, 2024

Do you see this in your log?

time=2024-04-11T08:26:43.688-04:00 level=INFO source=routes.go:1139 msg="Listening on [::]:11434 (version 0.1.32-rc1)"

@kellerkind84
Copy link
Author

I don't!

`❯ cat ~/.ollama/logs/server.log | grep -i listening
time=2024-04-10T21:12:53.994+02:00 level=INFO source=routes.go:1118 msg="Listening on 127.0.0.1:11434 (version 0.1.31)"
time=2024-04-10T21:14:45.409+02:00 level=INFO source=routes.go:1118 msg="Listening on 127.0.0.1:11434 (version 0.1.31)"
time=2024-04-10T21:17:09.948+02:00 level=INFO source=routes.go:1118 msg="Listening on 127.0.0.1:11434 (version 0.1.31)"
time=2024-04-10T21:31:55.355+02:00 level=INFO source=routes.go:1118 msg="Listening on 127.0.0.1:11434 (version 0.1.31)"

~
❯ echo $OLLAMA_HOST
0.0.0.0
`

I did the launchctl setenv thing, and I see the OLLAMA_HOST in any given terminal, but apart from that Ollama does not seem to care...

@dims
Copy link

dims commented Apr 11, 2024

restarted the server after running launchctl setenv OLLAMA_HOST "0.0.0.0" ?

@kellerkind84
Copy link
Author

Restarted the server and restarted my Mac.

@pdevine
Copy link
Contributor

pdevine commented Apr 12, 2024

@kellerkind84 is this working now? It's covered in the FAQ. As @dims mentioned, just:

  1. stop the ollama application;
  2. run launchctl setenv OLLAMA_HOST "0.0.0.0"
  3. restart ollama
  4. check in ~/.ollama/logs to see if "Listening on [::]:11434" is in one of the log files

Make sure you're looking in the last log file for step 4.

@kellerkind84
Copy link
Author

What? Why would it be working now? I clearly stated twice that I did both steps and it does not work? Did you change something?

@pdevine
Copy link
Contributor

pdevine commented Apr 12, 2024

@kellerkind84 no, it was unclear from your message. I just tried the steps and it works fine, so I'm having problems reproducing what you're seeing. What version of MacOS are you using?

@arvindsg
Copy link

@kellerkind84
Having a space after env variable can cause issues ollama starting on global interface
On windows this:-
'set OLLAMA_HOST=0.0.0.0:8080 && ollama serve'
fails with error Error: listen tcp: lookup tcp/8080 : unknown port

But explicitly setting variable using 'set OLLAMA_HOST=0.0.0.0:8080' and then ollama serve works properly

@kellerkind84
Copy link
Author

Yeah that should not have happened. But these lines are a starting point to find out what is wrong... my default shell is not exactly standard. So I'll test from the command line, maybe I'll get some helpful output. On Monday, though.

@kellerkind84
Copy link
Author

Alright, I had another look, fixed an error on my shell loading and even switched back to zsh. However, still not working when I start via the "app".

That said, simply running "ollama serve" works. Don't have to set the environment variable or anything.

It's an interesting workaround and working for now, but something does not work as expected here either way.

@gramata
Copy link

gramata commented Apr 19, 2024

I had the same issue.
Ollama on my mac mini stopped advertising the port 11434 to Tailscale.
I think it happened on upgrade from v0.1.31 to v0.1.32 as I was using ollama via tailscale without issue.

My setup is ollama installed via homebrew on m1 mac mini.
(fyi remember homebrew uses different directories for intel v apple silicon https://docs.brew.sh/Installation)

What seems to have worked for me is to update environment variable in:
/opt/homebrew/opt/ollama/homebrew.mxcl.ollama.plist

Steps I took that resolved issue:

  1. Check open ports with lsof -i -P | grep LISTEN
    In my case ollama was listed as TCP localhost:11434 (LISTEN)
    instead of the desired TCP *:11434 (LISTEN)

  2. update the homebrew.mxcl.ollama.plist:
    nano /opt/homebrew/opt/ollama/homebrew.mxcl.ollama.plist

Add the environment variable lines in plist format:

<key>EnvironmentVariables</key>
<dict>
    <key>OLLAMA_HOST</key>
    <string>0.0.0.0</string>
</dict>
  1. Restart ollama via brew services brew services restart ollama

On checking the open ports again it's now listed as desired TCP *:11434 (LISTEN)
Checking Tailscale admin page > machines (mac mini) > 'services' and port 11434 is now listed.

@kellerkind84
Copy link
Author

Thanks for the Tipp! I actually installed via download, but I might make the switch to homebrew. I was not even aware that ollama was available via homebrew.

@kellerkind84
Copy link
Author

Yeah that did the trick, thanks!

@owenzhao
Copy link

  1. Restart ollama via brew services brew services restart ollama

In my own experience, brew services restart ollama won't work again after Mac reboot. I have to brew services stop ollama first, then brew services start ollama to get the plist reloaded.

@pdevine
Copy link
Contributor

pdevine commented Apr 30, 2024

I'm going to go ahead and close this since there is a workaround. There are some changes coming for the mac version which will let you set this through a setting by clicking on the tray icon which should make everything a lot easier.

@pdevine pdevine closed this as completed Apr 30, 2024
@owenzhao
Copy link

I'm going to go ahead and close this since there is a workaround. There are some changes coming for the mac version which will let you set this through a setting by clicking on the tray icon which should make everything a lot easier.

There are two ollamas in brew, only the cask version has the menu icon(tray).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants