# Ollama: who can reach the API

By Vadim Nareyko, founder, Arviser. Published 2026-11-29 · Updated 2026-11-29 · Last reviewed 2026-11-29

## 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](https://github.com/nareyko/arviser-labs/blob/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/results/2026-11-29/run-4/summary.md)
- Check: [`check-ollama-api-exposure.sh [port | URL]`](https://github.com/nareyko/arviser-labs/blob/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/check-ollama-api-exposure.sh), `GET /api/version` without credentials; answers OPEN or COULD NOT TELL

## Short answer

Ollama's API has no key: "The local API at `http://localhost:11434` does not require authentication" ([Ollama docs](https://github.com/ollama/ollama/blob/v0.40.19/docs/api/authentication.mdx)). 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](https://github.com/ollama/ollama/blob/v0.40.19/scripts/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](https://github.com/nareyko/arviser-labs/blob/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/results/2026-11-29/run-4/summary.md), [raw files](https://github.com/nareyko/arviser-labs/tree/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/results/2026-11-29/run-4/raw)).

| 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](https://github.com/ollama/ollama/blob/v0.40.19/server/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
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](https://github.com/nareyko/arviser-labs/blob/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/check-ollama-api-exposure.sh)). 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](https://github.com/ollama/ollama/blob/v0.40.19/docs/faq.mdx)): "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":

```shell
systemctl daemon-reload
systemctl restart ollama
```

**Docker.** From the Docker docs ([port publishing](https://docs.docker.com/engine/network/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:

```console
$ 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](https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html)), with the example:

```nginx
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](https://nginx.org/en/docs/switches.html)).

**Warnings (ours):**

- **The FAQ's example value opens it.** A service with `Environment="OLLAMA_HOST=0.0.0.0:11434"` listens on every address; that is the line to remove or change.

- **Docker older than 28.0.** The Docker docs: "In releases older than 28.0.0, hosts within the same L2 segment (for example, hosts connected to the same network switch) can reach ports published to localhost." Check `docker version`. Upgrading the engine restarts the daemon, and with it your containers.

- **Before `docker rm`,** run `docker inspect ollama` and note the other flags (`--gpus`, `--device`, `-e`, `-v`), then start the new container with all of them and `-p 127.0.0.1:11434:11434`.

- **Removing or restarting** the container or the service drops loaded models and cuts off running requests.

- **Publishing to 127.0.0.1** cuts off clients on other machines, and containers that reach Ollama through the host gateway (`host.docker.internal`). Put such clients on Ollama's Docker network or behind the proxy.

- **The FAQ's example listens on plain HTTP** (`listen 80;`), so a Basic auth password travels unencrypted. Add TLS on the proxy before you rely on the password; we did not run TLS.

- **The FAQ's proxy example has no auth.** As printed, it answered our check with no key. A password on the proxy does not cover the Ollama port: in our lab the proxy answered 401 while the port next to it was OPEN. Run the check against both.

## What we ran

| Item | Value |
| --- | --- |
| Lab | [ollama-api-exposure](https://github.com/nareyko/arviser-labs/tree/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/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](https://github.com/nareyko/arviser-labs/blob/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/expected/EXPECTED-v3.md), 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` |

## Related pages

- [LiteLLM /public/mcp_hub (GHSA-28j3-9x3h-556f): tested on six versions, and a check for your instance](/library/tests/litellm-public-mcp-hub-ghsa-28j3)
- [Langflow auto_login (CVE-2026-9103): tested on four versions and four setups, and a check for your instance](/library/tests/langflow-auto-login-cve-2026-9103)
- [Langflow code-validation endpoint (CVE-2025-3248): tested on six versions, and a check for your instance](/library/tests/langflow-validate-code-cve-2025-3248)

## Sources

- Ollama docs, Authentication (docs/api/authentication.mdx at v0.40.19): https://github.com/ollama/ollama/blob/v0.40.19/docs/api/authentication.mdx (accessed 2026-11-29)
- Ollama docs, FAQ (docs/faq.mdx at v0.40.19): https://github.com/ollama/ollama/blob/v0.40.19/docs/faq.mdx (accessed 2026-11-29)
- Ollama source, scripts/install.sh at v0.40.19: https://github.com/ollama/ollama/blob/v0.40.19/scripts/install.sh (accessed 2026-11-29)
- Ollama source, Dockerfile at v0.40.19: https://github.com/ollama/ollama/blob/v0.40.19/Dockerfile (accessed 2026-11-29)
- Ollama source, server/routes.go at v0.40.19: https://github.com/ollama/ollama/blob/v0.40.19/server/routes.go (accessed 2026-11-29)
- Ollama releases on GitHub: https://github.com/ollama/ollama/releases (accessed 2026-11-29)
- Docker docs, port publishing: https://docs.docker.com/engine/network/port-publishing/ (accessed 2026-11-29)
- nginx docs, module ngx_http_auth_basic_module: https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html (accessed 2026-11-29)
- nginx docs, command-line parameters: https://nginx.org/en/docs/switches.html (accessed 2026-11-29)
- Our lab, arviser-labs at commit cf5c3d6, tested-threats/ollama-api-exposure: https://github.com/nareyko/arviser-labs/tree/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure (accessed 2026-11-29)
- Our lab, image configs of ollama/ollama read 2026-11-29: https://github.com/nareyko/arviser-labs/blob/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/results/2026-11-29/registry-config/image-env.txt (accessed 2026-11-29)
- Our lab, run 4 of 2026-11-29: summary, raw files and hashes: https://github.com/nareyko/arviser-labs/tree/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/results/2026-11-29/run-4 (accessed 2026-11-29)
- Our lab, copies of the Ollama files read, at v0.40.19 and v0.1.34: https://github.com/nareyko/arviser-labs/tree/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure/results/2026-11-29/source (accessed 2026-11-29)

## Corrections

No corrections.

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](https://creativecommons.org/licenses/by/4.0/). Code in [our lab](https://github.com/nareyko/arviser-labs/tree/cf5c3d656861acb3478adca8d274fba5da72e2dd/tested-threats/ollama-api-exposure): [MIT](https://opensource.org/license/mit). Quoted third-party material keeps its own terms.
