Arviser

Ollama: who can reach the API

Facts

Test
KB-T-0005 · AI applications, Cloud and infrastructure
Our test run
2026-11-29 · Our lab run 4: Ollama 0.1.34 and 0.40.19, nginx 1.30.8, 39 cells including 20 controls, 3 runs per cell
Tested by us
2026-11-29, official images ollama/ollama 0.1.34 and 0.40.19 (newest on 2026-11-29); 39 cells, 117 runs, lab run 4
Check
check-ollama-api-exposure.sh [port | URL], GET /api/version without credentials; answers OPEN or COULD NOT TELL
Next review
2027-05-29

Short answer

Ollama's API has no key: "The local API at http://localhost:11434 does not require authentication" (Ollama docs). So the only question is which addresses answer. In our lab the official Docker image answered on its network address, and the same binary started the way the Linux install script starts it answered on 127.0.0.1 only. Our check reports OPEN when Ollama answers at a non-loopback address or at a URL you give, and COULD NOT TELL otherwise. It has no answer that means closed.

What we measured

Official ollama/ollama images 0.1.34 and 0.40.19 (newest on 2026-11-29), by digest, on one internal Docker network with no published ports and no model. Requests: GET /api/version and the socket table only. The install-script setup is the image's binary with OLLAMA_HOST removed, standing in for the systemd unit the script writes, which sets only PATH (install.sh). The check ran inside Ollama's network namespace (as on the host) and from a neighbour container. 3 runs per cell, fresh containers, expected results written before the run (summary, raw files).

Setup Ollama log Check on the host Check from a neighbour
Image as shipped (OLLAMA_HOST=0.0.0.0:11434 in 0.40.19, 0.0.0.0 in 0.1.34) Listening on [::]:11434 OPEN OPEN
Install-script start (OLLAMA_HOST unset) Listening on 127.0.0.1:11434 COULD NOT TELL: answers on 127.0.0.1 only COULD NOT TELL: connection refused
OLLAMA_HOST=<container IP>:11434 (0.40.19) Listening on 172.20.0.4:11434 OPEN not run

Both versions gave the same answers. With nginx 1.30.8 in front of 0.40.19:

Setup Proxy URL, no credentials Ollama port Check on the Ollama host
Basic auth, image as shipped 401, COULD NOT TELL OPEN OPEN
Basic auth, Ollama on 127.0.0.1 401, COULD NOT TELL refused, COULD NOT TELL COULD NOT TELL: 127.0.0.1 only
The FAQ's nginx example as printed (no auth), Ollama on 127.0.0.1 OPEN not run COULD NOT TELL: 127.0.0.1 only
Proxy passing the client's host name, Ollama on 127.0.0.1 OPEN not run not run

All 39 cells, including 20 controls, matched the expectation in all 3 runs. Two points the docs do not state: OLLAMA_HOST=0.0.0.0 showed up as one IPv6 wildcard socket, [::]:11434, which a search for 0.0.0.0:11434 misses; and the FAQ's proxy example, which has no auth, answered with no key. In the last row the client's host name was the Ollama container's own host name, which Ollama's Host check accepts (routes.go, allowedHost); other names were not run.

Not run: the install script itself, systemd, Docker port publishing, ufw and firewalld, Docker Desktop, the macOS and Windows apps, Kubernetes, IPv6 networks, TLS, and other versions.

The check

On the Linux host where Ollama runs, or from another machine with a URL:

sh check-ollama-api-exposure.sh                        # port 11434; or give another port
sh check-ollama-api-exposure.sh http://10.0.0.5:11434  # or your proxy URL

It needs a POSIX shell with awk, sed, grep and curl (script). On the host it reads the listening sockets from /proc/net/tcp and /proc/net/tcp6, and the host's own addresses from /proc/net/fib_trie, and sends GET /api/version to each non-loopback address Ollama listens on. With a URL it sends one GET /api/version. It ignores proxy variables and ~/.curlrc, and never sends a model name, a prompt, a pull or a delete. Run it only on hosts you own or are allowed to test.

Exit Answer What it means What it does not tell you
1 OPEN Ollama answered with no credentials at a non-loopback address of the host, or at your URL Which machines can reach that address: your firewall and network decide. A server that imitates Ollama's version answer also gives OPEN (our control)
2 COULD NOT TELL Anything else. The lines above it say what was seen: answers on 127.0.0.1 only, a 401 or 403, a refused connection, a timeout, a 407, no Ollama on that port, not Linux Anything about other paths. A reverse proxy, a tunnel, a Docker port forward or another port can still reach an Ollama that answers on 127.0.0.1 only; a 401 at a proxy says nothing about the Ollama port behind it

In the lab it gave COULD NOT TELL for a hung port (a timeout in every run), a catch-all page, a 404, an unknown host, a refused port, a redirect, a 500, a 401, a 403, a 407, JSON that is not Ollama's, a bad argument, nothing listening and a non-Ollama server on the port, and OPEN for a server imitating Ollama's version answer. With proxy variables or a ~/.curlrc proxy set in the client, it still reached the target.

Fix

Install script (systemd). From the Ollama FAQ (FAQ): "Ollama binds 127.0.0.1 port 11434 by default. Change the bind address with the OLLAMA_HOST environment variable." To change it: "Edit the systemd service by calling systemctl edit ollama.service", "For each environment variable, add a line Environment under section [Service]", then "Reload systemd and restart Ollama":

systemctl daemon-reload
systemctl restart ollama

Docker. From the Docker docs (port publishing): "Publishing container ports is insecure by default." "If you include the localhost IP address (127.0.0.1, or ::1) with the publish flag, only the Docker host can access the published container port." Their example:

$ docker run -p 127.0.0.1:8080:80 -p '[::1]:8080:80' nginx

Also from the same page: "all ports of containers on bridge networks are accessible from the Docker host and other containers connected to the same network."

A proxy for other machines. The FAQ's nginx example sends requests to http://localhost:11434 with proxy_set_header Host localhost:11434. The nginx docs: "The ngx_http_auth_basic_module module allows limiting access to resources by validating the user name and password using the 'HTTP Basic Authentication' protocol" (auth_basic), with the example:

location / {
    auth_basic           "closed site";
    auth_basic_user_file conf/htpasswd;
}

Put the two auth_basic lines inside the FAQ's location / block. Pasted as two blocks, they give two location / blocks, and nginx -t fails with duplicate location "/" (our test). The password file "can be generated using the 'htpasswd' utility from the Apache HTTP Server distribution or the 'openssl passwd' command". Before reload, run nginx -t, which the nginx docs describe as "test the configuration file" (nginx command line).

Warnings (ours):

What we ran

Item Value
Lab ollama-api-exposure, arviser-labs commit cf5c3d6
Images ollama/ollama 0.1.34 sha256:a92fbb91…f0ff, 0.40.19 sha256:937b59fe…5ba3 (amd64); curl 8.23.0; nginx 1.30.8; Docker Engine 29.10.0
Installed version Read through /api/version and ollama --version: matched the tag
Runs Run 4 with check v3: 39 cells, 117 runs, 3 per cell, all matched
Expected results Written before the run, 2026-11-29T06:45:13Z, hashed; earlier versions kept. The file says it had seen run 4 and two check rounds; it was written before run 4, after runs 1 to 3 and one check round
Runner, date Claude Opus 5.5, 2026-11-29
Expiry Stale when Ollama releases after 0.40.19, or the install script or image changes OLLAMA_HOST

Sources

Primary records first. Record identifiers link from the facts box.

Vendor documentation and statements

Our lab

Corrections

No corrections.

Report an error to contact@arviser.com.

How this page was made: Claude Opus 5.5, an AI model, ran the lab, read the Ollama, Docker and nginx docs and the Ollama source, and wrote this page. A separate AI agent checked the claims against the sources and the lab record in three rounds; the page and the lab record were corrected after the first two, and the third found nothing that had to be fixed. The page was simplified under a writing rule Vadim Nareyko set on 29 November 2026. Vadim Nareyko approved the tested-threats programme, which this page follows, on 27 November 2026. This page was not reviewed by Vadim Nareyko. On 28 November 2026 Vadim Nareyko decided that new pages are published after the linters and an independent check, without that review.

Text and data on this page: CC BY 4.0. Code in our lab: MIT. Quoted third-party material keeps its own terms.

Request a security review