[GH-ISSUE #1179] Why is this fixed to localhost? #599

Closed
opened 2026-04-12 10:18:41 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @oderwat on GitHub (Nov 17, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/1179

I want to run the server on one of my local machines and use if from from other ones in the same private network. I wonder why this (and some other similar software) is only running on localhost? I can rewrite it to use another host. I just wonder why it is how it is?

Originally created by @oderwat on GitHub (Nov 17, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/1179 I want to run the server on one of my local machines and use if from from other ones in the same private network. I wonder why this (and some other similar software) is only running on localhost? I can rewrite it to use another host. I just wonder why it is how it is?
Author
Owner

@oliverbob commented on GitHub (Nov 17, 2023):

It can actually run on any server. Not just localhost. Here for instance is a customized version. You can run this on any server of your choice.

You simply just rebuild it from source or do however you like with docker and then expose your running installation port to a reverse proxy.

Just do:

OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve

Or with docker, you can specify a port.

docker run -d -v ./ollama -p 11434:11434 -e OLLAMA_ORIGINS="*" --name ollama ollama/ollama

Then from there do a reverse proxy to forward 11434 to https via 443 or standard ssl.

You can verify whether your port is exposed with netstat -tunl

Look for the 0.0.0.0:11434 or :::11434 because that means that your ollama server is exposed to your specified port, otherwise, if you just run it with ollama serve, you'll just have 127.0.0.1:11434, meaning your ollama server is not exposed.

<!-- gh-comment-id:1817099547 --> @oliverbob commented on GitHub (Nov 17, 2023): It can actually run on any server. Not just localhost. Here for instance is a customized version. You can run this on any server of your choice. You simply just rebuild it from source or do however you like with docker and then expose your running installation port to a reverse proxy. Just do: `OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve` Or with docker, you can specify a port. `docker run -d -v ./ollama -p 11434:11434 -e OLLAMA_ORIGINS="*" --name ollama ollama/ollama` Then from there do a reverse proxy to forward 11434 to https via 443 or standard ssl. You can verify whether your port is exposed with netstat -tunl Look for the 0.0.0.0:11434 or :::11434 because that means that your ollama server is exposed to your specified port, otherwise, if you just run it with ollama serve, you'll just have 127.0.0.1:11434, meaning your ollama server is not exposed.
Author
Owner

@oderwat commented on GitHub (Nov 17, 2023):

OK. I missed the OLLAMA_HOST / OLLAMA_ORIGINS env variables. I just found them in the FAQ. I think this belongs into the documentation.

<!-- gh-comment-id:1817104027 --> @oderwat commented on GitHub (Nov 17, 2023): OK. I missed the OLLAMA_HOST / OLLAMA_ORIGINS env variables. I just found them in the FAQ. I think this belongs into the documentation.
Author
Owner

@Hi-Angel commented on GitHub (Mar 25, 2025):

Just do:

OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve

Doesn't seem to be working, see:

# OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS="*" ollama serve 2>&1 | grep Listening
time=2025-03-25T09:30:13.740+03:00 level=INFO source=routes.go:1238 msg="Listening on 127.0.0.1:11434 (version 0.0.0)"

It says it's listening on 127.0.0.1 instead of 0.0.0.0. And expectedly, nc -v LAN_IP 11434 results in "Connection refused".

That is with 0.5.7 released a few months ago.

<!-- gh-comment-id:2750226524 --> @Hi-Angel commented on GitHub (Mar 25, 2025): > Just do: > > `OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS=* ollama serve` Doesn't seem to be working, see: ```haskell # OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS="*" ollama serve 2>&1 | grep Listening time=2025-03-25T09:30:13.740+03:00 level=INFO source=routes.go:1238 msg="Listening on 127.0.0.1:11434 (version 0.0.0)" ``` It says it's listening on `127.0.0.1` instead of `0.0.0.0`. And expectedly, `nc -v LAN_IP 11434` results in "Connection refused". That is with `0.5.7` released a few months ago.
Author
Owner

@Hi-Angel commented on GitHub (Apr 1, 2025):

Found out it may not work on Ubuntu due to a bug snap Ollama package. Reported it the last week to the package maintainer, but got no reply.

A workaround is to use:

OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS="*" sh -c 'echo "ollama serve" | snap run --shell ollama'
<!-- gh-comment-id:2769219909 --> @Hi-Angel commented on GitHub (Apr 1, 2025): Found out it may not work on Ubuntu due to a bug `snap` Ollama package. Reported it the last week to the package maintainer, but got no reply. A workaround is to use: ```bash OLLAMA_HOST=0.0.0.0 OLLAMA_ORIGINS="*" sh -c 'echo "ollama serve" | snap run --shell ollama' ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#599