Reference · Local AI servers
Port 11434: check whether Ollama is exposed to the network
Check whether Ollama's API on port 11434 listens on 0.0.0.0, pin it to 127.0.0.1 with OLLAMA_HOST on Windows 11, macOS and a Linux systemd override, and block the port in the firewall.
| Target artifact | The Ollama REST API on TCP port 11434, set by the OLLAMA_HOST environment variable and the app's Expose Ollama to the network setting. |
|---|---|
| Default behaviour | Listens on 127.0.0.1:11434, this computer only. The API has no authentication, so once it listens on 0.0.0.0 anyone who can reach the port can run, pull and delete models. |
| Safe state | Listening on 127.0.0.1:11434 or [::1]:11434 only; Expose Ollama to the network off; no OLLAMA_HOST=0.0.0.0 anywhere; Ollama 0.35.0 or later. |
| Check on Windows | Get-NetTCPConnection -State Listen -LocalPort 11434 | Select-Object LocalAddress, LocalPort, OwningProcess |
| Check on Linux | sudo ss -tlnp | grep 11434 |
| Check on macOS | sudo lsof -nP -iTCP:11434 -sTCP:LISTEN |
| Check from another device | curl --max-time 5 http://SERVER_IP:11434/api/version |
| Fix on Windows | [Environment]::SetEnvironmentVariable('OLLAMA_HOST', '127.0.0.1:11434', 'User'), then quit and restart Ollama |
| Fix on Linux | sudo systemctl edit ollama.service and add Environment="OLLAMA_HOST=127.0.0.1:11434" under [Service] |
| Fix on macOS | launchctl unsetenv OLLAMA_HOST, then quit and reopen Ollama |
| Fix in Docker | publish with -p 127.0.0.1:11434:11434, never -p 11434:11434 |
Read the result
| Listening address | Who can reach the API |
|---|---|
127.0.0.1:11434 or [::1]:11434 | This computer only |
0.0.0.0:11434, *:11434 or [::]:11434 | Every network interface: Wi-Fi, Ethernet and any VPN |
A network address, such as 192.168.1.20:11434 | Anyone who can reach that network |
The listening address shows what Ollama asked for; the test from a second device shows what the network allows. A JSON reply with a version number means the API is reachable from that device. "Connection refused" or a timeout means it is not. In Windows PowerShell, type curl.exe rather than curl, which is an alias for Invoke-WebRequest there.
Exposed servers are found quickly: in a study published in January 2026, SentinelLABS and Censys counted 175,108 unique Ollama hosts answering on the public internet over 293 days of scanning.
Pin Ollama to 127.0.0.1
Ollama binds to 127.0.0.1:11434 unless OLLAMA_HOST says otherwise, so the fix is to find what set it and set it back.
Windows 11
- In the Ollama app's settings, turn off Expose Ollama to the network. It is off by default.
- Look for the variable in both scopes:
[Environment]::GetEnvironmentVariable('OLLAMA_HOST', 'User')
[Environment]::GetEnvironmentVariable('OLLAMA_HOST', 'Machine')- Pin it to the loopback address, and clear a machine-wide value if the second line printed one. The second command needs PowerShell opened with Run as administrator:
[Environment]::SetEnvironmentVariable('OLLAMA_HOST', '127.0.0.1:11434', 'User')
[Environment]::SetEnvironmentVariable('OLLAMA_HOST', $null, 'Machine')- Quit Ollama from its taskbar icon, start it again from the Start menu, and run the check again. Ollama reads the variables only when it starts.
Linux with systemd (the official installer)
systemctl cat ollama.service | grep -n OLLAMA_HOST
sudo systemctl edit ollama.serviceIn the editor that opens, add these lines, then save and close it. They are stored in /etc/systemd/system/ollama.service.d/override.conf:
[Service]
Environment="OLLAMA_HOST=127.0.0.1:11434"If systemctl cat showed another file setting OLLAMA_HOST=0.0.0.0, remove that line too. Then reload, restart and check:
sudo systemctl daemon-reload
sudo systemctl restart ollama
sudo ss -tlnp | grep 11434macOS
Turn off Expose Ollama to the network in the Ollama app's settings. Then look for a value set through launchctl, and clear it:
launchctl getenv OLLAMA_HOST
launchctl unsetenv OLLAMA_HOSTQuit and reopen Ollama. If the value comes back after you sign in again, something sets it at login; search your launch agents for it:
grep -rl OLLAMA_HOST ~/Library/LaunchAgents 2>/dev/nullDocker
Ollama's image sets OLLAMA_HOST=0.0.0.0 inside the container; that is expected. What matters is the host side of the published port:
docker ps --format 'table {{.Names}}\t{{.Ports}}'0.0.0.0:11434->11434/tcp means every interface. Recreate the container on the loopback address; the named volume keeps the downloaded models:
docker stop ollama && docker rm ollama
docker run -d -v ollama:/root/.ollama -p 127.0.0.1:11434:11434 --name ollama ollama/ollamaOn Docker Engine releases older than 28.0.0, other hosts on the same local network segment could still reach ports published to 127.0.0.1. Check with docker version.
Block the port as a second layer
Binding to 127.0.0.1 is the fix. A firewall rule catches the day someone turns the network setting back on.
Windows Defender Firewall
New-NetFirewallRule -DisplayName 'Block inbound Ollama 11434' -Direction Inbound -Protocol TCP -LocalPort 11434 -Action BlockAn explicit block rule takes precedence over any conflicting allow rule, including one created when someone clicked Allow at Windows' first-run prompt.
Ubuntu with UFW
UFW uses the first rule that matches, so insert the block at the top:
sudo ufw status numbered
sudo ufw insert 1 deny 11434/tcpIf the numbered list is empty, ufw insert answers ERROR: Invalid position '1'; run sudo ufw deny 11434/tcp instead.
If one other computer genuinely needs the API, delete the deny rule and allow that address alone with sudo ufw allow from 192.168.1.50 to any port 11434 proto tcp. Ports published by Docker bypass UFW; see Docker published ports.
macOS
The macOS firewall decides per application, not per port, so there is no port rule to add. Keep Ollama on 127.0.0.1.
Troubleshooting
The check still shows 0.0.0.0 after the change
- Ollama was not restarted. It reads
OLLAMA_HOSTat start-up only. - On Linux, another drop-in file sets the variable after yours.
systemctl cat ollama.serviceprints every file in the order systemd reads them. - On Windows, a machine-wide value needs an Administrator PowerShell to clear, and the app setting can turn exposure back on.
- In Docker, read the
docker psport column, not the variable inside the container.
The test from another device still connects
- Another program is listening on the port. On Windows, the
OwningProcessnumber in the check is the process ID;Get-Process -Id NUMBERnames it. On Linux,ss -pshows the process name. - A reverse proxy such as nginx or Caddy forwards another port to
127.0.0.1:11434. Check its configuration. - The device tested over IPv6. If Ollama listens on
[::], a router's IPv6 firewall may let traffic in even though IPv4 address sharing hides the computer.
Which Ollama version is safe
Run ollama --version. Version 0.35.0 fixes CVE-2026-103663, a path traversal in /api/pull that writes files outside the model store; versions 0.34.2 and later before 0.35.0 are affected. The CVE record adds that where the server can write to /usr/lib/ollama, the default in most of Ollama's Docker images, the planted file runs as root at the next restart.
Related guides and lookups
Sources
- Ollama FAQ: binding address and environment variables
- Ollama app settings source, "Expose Ollama to the network"
- Docker: port publishing
- Docker: packet filtering and firewalls
- Microsoft Learn: Get-NetTCPConnection
- Microsoft Learn: Windows Firewall rules and precedence
- Debian manual: ufw
- SentinelLABS: Ollama hosts exposed on the internet, 29 January 2026
- CERT Polska: CVE-2026-103663
- OpenCVE: CVE-2026-103663