Guide 1 · Local AI
Lock down local AI servers: Ollama, LM Studio and Open WebUI
Find out whether your local model server answers the network, bind it to 127.0.0.1, close the ports in the firewall, and keep it patched.
Why it matters
Local model servers are built to answer HTTP requests from other programs, and by default they do not ask who is calling. Ollama's API has no built-in authentication. LM Studio added optional API tokens in version 0.4.0, but they are off by default. Open WebUI makes the first account that signs up its administrator.
That is safe while the server listens only on the computer itself. It stops being safe the moment it listens on a network address: anyone who can reach the port can run your models, pull or delete them, and reach any bug in the server. 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, in 130 countries.
Warning Recent Ollama vulnerabilities
- CVE-2026-103663: a path traversal in
/api/pullwrites files outside the model store. On Linux, if/usr/lib/ollamais writable, the planted file runs as root at the next restart. Affects 0.34.2 and later versions before 0.35.0; fixed in 0.35.0 (CERT Polska, 8 October 2026). - CVE-2026-7482 ("Bleeding Llama"): an out-of-bounds read reached through
/api/createleaks memory, which is sent out through/api/push. Fixed in 0.17.1. - CVE-2026-42248 and CVE-2026-42249: the Windows updater skips signature checks and has a path traversal. CERT Polska confirmed them in 0.12.10 to 0.17.5 and did not test other versions. The researcher who reported them said in May 2026 that 0.23.0 still had no patch; Ollama 0.23.3 then shipped pull request #16100, "harden update flows", which Mondoo's analysis names as the fix, although CERT Polska's advisory still names no fixed version. On Windows, with any version older than 0.23.3, turn off Auto-download updates in the Ollama app where that setting exists, then install the current release yourself.
- GitHub's advisory database rates Ollama's missing API authentication (CVE-2025-63389) as critical; it lists releases up to 0.13.5 as affected and names no patched version. The fix is to keep the API off the network.
Default ports
| Program | Default address | What answers there |
|---|---|---|
| Ollama | 127.0.0.1:11434 | The Ollama REST API |
| LM Studio | localhost:1234 | The API server, once you start it |
| Open WebUI | 8080 inside the container, published as 3000 in its docs | The web interface and its accounts |
How to read a listening address:
127.0.0.1or::1: this computer only. This is what you want.0.0.0.0,::,[::]or*: every network interface, including Wi-Fi, Ethernet and any VPN.- A specific address such as
192.168.1.20: anyone who can reach that network.
Step 1: see what is listening
sudo ss -tulpn | grep -E ':(11434|1234|3000|8080)\b'Get-NetTCPConnection -State Listen -LocalPort 11434, 1234, 3000, 8080 -ErrorAction SilentlyContinue |
Select-Object LocalAddress, LocalPort, OwningProcess,
@{ Name = 'Process'; Expression = { (Get-Process -Id $_.OwningProcess).ProcessName } }sudo lsof -nP -iTCP -sTCP:LISTEN | grep -E ':(11434|1234|3000|8080) 'Any line showing 0.0.0.0, ::, * or a network address on these ports means the service can be reached from outside the computer, unless a firewall stops it.
Step 2: test from another device
A listening address tells you what the program asked for; a test from a second device tells you what the network allows. Run these from another computer on the same network, replacing SERVER_IP with the address of the machine you are checking:
curl --max-time 5 http://SERVER_IP:11434/api/version
curl --max-time 5 http://SERVER_IP:1234/v1/models
curl --max-time 5 -I http://SERVER_IP:3000/In Windows PowerShell, type curl.exe instead of curl, because curl is an alias for Invoke-WebRequest there.
- "Connection refused" or a timeout: not reachable from that device.
- A JSON reply, or an HTTP status line: reachable. Fix it with the steps below.
Note IPv6 is not hidden by your router's address sharing
Home routers share one public IPv4 address, which hides devices behind it. IPv6 works differently: each device can have its own public address. If the server listens on [::] and the router's IPv6 firewall allows inbound traffic, the port can be reachable from the internet directly. Check the router's IPv6 firewall setting.
Step 3: bind Ollama to 127.0.0.1
Ollama binds to 127.0.0.1:11434 unless something sets the OLLAMA_HOST environment variable. Find whatever set it.
Ubuntu and other Linux systems using 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:
[Service]
Environment="OLLAMA_HOST=127.0.0.1:11434"If systemctl cat showed another line setting OLLAMA_HOST=0.0.0.0, remove that line from its file as well. Then reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart ollama
sudo ss -tlnp | grep 11434The last command should show 127.0.0.1:11434.
Windows
- Open the Ollama app's settings and make sure Expose Ollama to the network is off. It is off by default.
- Check whether an environment variable overrides it:
[Environment]::GetEnvironmentVariable('OLLAMA_HOST', 'User')
[Environment]::GetEnvironmentVariable('OLLAMA_HOST', 'Machine')If either line prints 0.0.0.0 or a network address, clear it. The second line needs PowerShell running as Administrator:
[Environment]::SetEnvironmentVariable('OLLAMA_HOST', $null, 'User')
[Environment]::SetEnvironmentVariable('OLLAMA_HOST', $null, 'Machine')Quit Ollama from its taskbar icon, start it again from the Start menu, and repeat Step 1.
macOS
Turn off Expose Ollama to the network in the Ollama app's settings, then check for a variable set through launchctl:
launchctl getenv OLLAMA_HOST
launchctl unsetenv OLLAMA_HOSTQuit and reopen Ollama.
Docker
Ollama's documented Docker command publishes port 11434 on every host interface, and the image sets OLLAMA_HOST=0.0.0.0 inside the container. Docker's own documentation warns that published ports bypass UFW and firewalld rules, so a host firewall does not protect them.
docker ps --format 'table {{.Names}}\t{{.Ports}}'0.0.0.0:11434->11434/tcp means the port is open on every interface. Recreate the container published on the loopback address only. The named volume keeps your 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/ollamaWarning Old Docker Engine versions
On Docker Engine older than 28.0.0, ports published to 127.0.0.1 could still be reached by other machines on the same local network segment. Check with docker version and update the engine if it is older.
Browser access and cloud features
OLLAMA_ORIGINS decides which web pages may call the API from a browser. Leave it unset unless a specific web app needs it, and never set it to *. By default Ollama already allows localhost, 127.0.0.1 and 0.0.0.0 on any port, plus the app://, file://, tauri://, vscode-webview:// and vscode-file:// schemes; values you add extend that list rather than replace it.
If you do not use Ollama's cloud models, setting OLLAMA_NO_CLOUD=1, or "disable_ollama_cloud": true in ~/.ollama/server.json, keeps Ollama local-only.
Step 4: LM Studio
- In LM Studio, open the Developer page and its server settings, and turn off Serve on Local Network.
- On LM Studio 0.4.0 or newer, turn on the server setting that requires authentication for each request. Programs then send their token in an
Authorization: Bearerheader. - If you start the server from the command line, bind it explicitly:
lms server start --port 1234 --bind 127.0.0.1--bind defaults to 127.0.0.1; 0.0.0.0 opens every interface. The LMS_SERVER_HOST environment variable sets the same thing, so check it if the server keeps appearing on the network.
Step 5: Open WebUI
Publish Open WebUI on the loopback address only. This is the command from its documentation with 127.0.0.1: added in front of the published port and without its -e WEBUI_SECRET_KEY=your-secret-key option; to set your own key, see Accounts and the secret key:
docker run -d -p 127.0.0.1:3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main- Open
http://127.0.0.1:3000and create your account straight away. The first account becomes the administrator. - Check in the Admin Panel that new sign-ups are off; since version 0.8.4, Open WebUI closes sign-up by itself after the first account. The
ENABLE_SIGNUPenvironment variable is only read at first launch; after that, the value saved in the Admin Panel takes precedence. - Leave
DEFAULT_USER_ROLEat its default,pending, so any new account needs approval. - Keep it updated. CVE-2025-64496 let a malicious "Direct Connections" model server run JavaScript in the user's browser and steal their token, leading to code execution for users allowed to add tools. It was fixed in 0.6.35, and Direct Connections is off by default. Version 0.9.0 removed a race in which two sign-ups arriving together could both become administrators.
Step 6: firewall rules as a second layer
Binding to 127.0.0.1 is the real fix. A firewall rule is the backstop for the day someone flips a setting back.
Ubuntu with UFW
sudo ufw status verbose
sudo ufw status numberedThe first command should report Default: deny (incoming). In the numbered list, look for any ALLOW rule on ports 11434, 1234, 3000 or 8080 that you did not mean to add, and remove it by its number:
sudo ufw delete RULE_NUMBERIf exactly one other computer needs the API, allow only that address:
sudo ufw allow from 192.168.1.50 to any port 11434 proto tcpRemember that Docker-published ports bypass these rules.
Windows Defender Firewall
When a program first listens on the network, Windows may ask whether to allow it. If someone clicked Allow, a rule exists. List the rules attached to Ollama:
Get-NetFirewallApplicationFilter | Where-Object Program -like '*ollama*' | Get-NetFirewallRule |
Select-Object DisplayName, Enabled, Direction, Action, ProfileAdd explicit inbound block rules. In Windows Defender Firewall, an explicit block rule takes precedence over a conflicting allow rule:
New-NetFirewallRule -DisplayName 'Block inbound Ollama 11434' -Direction Inbound -Protocol TCP -LocalPort 11434 -Action Block
New-NetFirewallRule -DisplayName 'Block inbound LM Studio 1234' -Direction Inbound -Protocol TCP -LocalPort 1234 -Action BlockStep 7: remote access without exposing the port
If you need the model server from a laptop, bring the laptop to the server rather than the server to the network.
An SSH tunnel forwards a port on your laptop to the server's loopback address:
ssh -N -L 11434:127.0.0.1:11434 USER@AI_SERVERWhile it runs, http://127.0.0.1:11434 on the laptop reaches the server's Ollama, and nothing new listens on the server's network interfaces.
A private overlay network such as WireGuard or Tailscale also works. Bind the service to the overlay interface's address rather than to 0.0.0.0. A service bound to that address can fail to start at boot if it starts before the interface: see WireGuard and Tailscale binding.
Step 8: keep it patched
ollama --versionOn Linux, the official installer also updates an existing installation:
curl -fsSL https://ollama.com/install.sh | shThe Windows and macOS apps update themselves; on Windows, see the warning about the updater at the top of this guide.
Checklist
- Step 1 shows
127.0.0.1or::1for ports 11434, 1234, 3000 and 8080. - The test from a second device fails to connect.
- No Docker container publishes these ports on
0.0.0.0. - Open WebUI's administrator account exists and new sign-ups are off.
- Ollama is 0.35.0 or later.
- The firewall's inbound default is deny, with no stray allow rules for these ports.
Quick lookups
One-line checks and fixes for the ports, files and settings in this guide, one page each.
Sources
- Ollama FAQ: binding address, environment variables, cloud setting
- Ollama app settings source, "Expose Ollama to the network"
- Ollama default allowed origins
- SentinelLABS: Ollama hosts exposed on the internet, 29 January 2026
- CERT Polska: CVE-2026-103663
- CERT Polska: CVE-2026-42248
- Help Net Security: unpatched flaws in Ollama's Windows auto-updater, 5 May 2026
- Ollama: release v0.23.3, 12 May 2026
- Mondoo: three Ollama CVEs, Bleeding Llama and the Windows updater flaws, 11 May 2026
- OSV: CVE-2026-7482
- GitHub advisory for CVE-2025-63389
- Docker: packet filtering and firewalls
- Docker: port publishing
- LM Studio: serve on local network
- LM Studio: authentication
- LM Studio: lms server start
- Open WebUI: quick start
- Open WebUI: environment configuration
- Open WebUI: hardening Open WebUI
- Open WebUI: first-run administrator promotion
- OpenCVE: CVE-2025-64496