- The default Ollama port is 11434, served over plain HTTP and bound to
127.0.0.1(localhost only). - Change it with the
OLLAMA_HOSTenvironment variable — e.g.OLLAMA_HOST=127.0.0.1:11435. There is noOLLAMA_PORTvariable. - To reach Ollama from another machine, bind to
0.0.0.0:11434and open the firewall — but the API has no authentication, so restrict it to a trusted network or put a reverse proxy in front. - Verify with
curl http://127.0.0.1:11434, which returnsOllama is running.
Ollama listens on port 11434 by default, over HTTP, bound to the loopback address 127.0.0.1. So the API base URL on the machine itself is http://127.0.0.1:11434. Because it binds to loopback rather than all interfaces, nothing outside that machine can reach it until you deliberately change the bind address.
- What Actually Runs on Port 11434
- OLLAMA_HOST: The One Variable That Controls the Port
- Changing the Ollama Port on Linux
- Changing the Ollama Port on macOS
- Changing the Ollama Port on Windows
- Verifying the Server Is Listening
- Making Ollama Reachable From Other Machines
- Diagnosing a Port Conflict
- Docker and WSL
- Frequently asked questions
- Quick Reference
What Actually Runs on Port 11434
Port 11434 is the Ollama HTTP server — the same process that ollama serve starts, and the same one the desktop app starts in the background. Every part of Ollama talks to it: the ollama CLI, the desktop chat window, and any third-party client you point at it.
| Endpoint | Purpose |
|---|---|
GET / | Health check — returns the plain text Ollama is running |
GET /api/tags | Lists locally installed models as JSON |
POST /api/generate, POST /api/chat | Native Ollama inference endpoints |
POST /api/pull, DELETE /api/delete | Model management — download and remove models |
/v1/chat/completions | OpenAI-compatible layer, for SDKs that expect an OpenAI base URL |
Note that row for /api/pull and /api/delete. Anyone who can reach the port can download multi-gigabyte models onto your disk or delete the ones you have. That is the security story in one line, and it is why the default bind is loopback. If you are still deciding what to install locally, the Ollama models list covers what is available and how large each one is.
OLLAMA_HOST: The One Variable That Controls the Port
Both the bind address and the port come from a single environment variable, OLLAMA_HOST. There is no separate port setting and no config file that overrides it.
| Value | Result |
|---|---|
| unset | Listens on 127.0.0.1:11434 |
127.0.0.1:11435 | Same loopback-only behaviour, different port |
0.0.0.0:11434 | Listens on every IPv4 interface — reachable from the LAN |
192.168.1.50:11434 | Listens on one specific interface only |
Always write it as host:port. Shorter forms are accepted in some versions, but the explicit pair behaves consistently across all of them.
One gotcha catches nearly everyone: OLLAMA_HOST is read by the client as well as the server. If you move the server to port 11435 but your terminal still has the default, ollama list will fail with a connection error while the server is perfectly healthy. Set the variable in both places, or run the CLI as OLLAMA_HOST=127.0.0.1:11435 ollama list.
Changing the Ollama Port on Linux
The Linux install script registers a systemd service, so environment variables in your shell are irrelevant — you have to put them in the unit. Use a drop-in override rather than editing the shipped unit file, which package upgrades will overwrite:
sudo systemctl edit ollama.serviceAdd this block (on newer systemd, put it between the ### Anything between here... marker comments):
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"That writes /etc/systemd/system/ollama.service.d/override.conf. Apply it:
sudo systemctl daemon-reload
sudo systemctl restart ollama
sudo systemctl status ollamaAdd one Environment= line per variable — a second line does not replace the first. If you are also relocating model storage, Environment="OLLAMA_MODELS=/mnt/models" goes in the same block.
If you run ollama serve manually
No systemd involved, so just export it: OLLAMA_HOST=0.0.0.0:11434 ollama serve. Make sure the systemd service is stopped first (sudo systemctl stop ollama) or the two will fight over the port.
Changing the Ollama Port on macOS
The macOS app is launched by the GUI session, which does not inherit your shell profile. Exporting OLLAMA_HOST in .zshrc changes the CLI but not the background server. Use launchctl instead:
launchctl setenv OLLAMA_HOST "0.0.0.0:11434"Then quit Ollama from the menu bar icon and relaunch it. The new value only applies to processes started afterwards.
launchctl setenv does not survive a reboot. For a permanent change you need to re-run it at login — a LaunchAgent plist, or a login item that runs the command. Recent versions of the macOS app also expose a network-access toggle in Settings; if your build has it, prefer it, since it persists properly. Check the app’s own settings pane before building a LaunchAgent, and see the Ollama complete guide for what else lives in there.
Changing the Ollama Port on Windows
Ollama on Windows runs as a normal user process with a system tray icon, so a user-level environment variable is enough.
- Press Win, type environment variables, and open Edit the system environment variables → Environment Variables…
- Under User variables, click New.
- Name:
OLLAMA_HOST. Value:0.0.0.0:11434(or your chosen port). - Click OK on both dialogs.
- Right-click the Ollama tray icon and choose Quit, then start Ollama again from the Start menu.
Step 5 is the one people skip. Closing the window does not stop the server; it keeps running with the old value. Equivalently from a terminal: setx OLLAMA_HOST "0.0.0.0:11434" — but setx only affects processes launched after it runs, so the quit-and-relaunch is still required. If you are setting this up from scratch, the Ollama installation guide walks through the Windows installer end to end.
Verifying the Server Is Listening
Two checks, in this order: is something bound to the port, and is that something Ollama?
| Platform | Command |
|---|---|
| Any | curl http://127.0.0.1:11434 → Ollama is running |
| Any | curl http://127.0.0.1:11434/api/tags → JSON list of models |
| Linux | sudo ss -tlnp | grep 11434 |
| macOS | lsof -nP -iTCP:11434 -sTCP:LISTEN |
| Windows | netstat -ano | findstr :11434 |
| Windows (PowerShell) | Get-NetTCPConnection -LocalPort 11434 |
Read the local address column carefully. 127.0.0.1:11434 means loopback only — a remote machine will never connect, no matter what the firewall says. 0.0.0.0:11434 or *:11434 means all interfaces.
Making Ollama Reachable From Other Machines
Binding to 0.0.0.0 is necessary but usually not sufficient. Three things must all be true: the server is bound to a non-loopback address, the host firewall allows inbound TCP on the port, and the client is using the host’s LAN IP rather than localhost.
Firewall rules
| Platform | How to allow inbound TCP 11434 |
|---|---|
| Windows | PowerShell as Administrator: New-NetFirewallRule -DisplayName "Ollama" -Direction Inbound -Protocol TCP -LocalPort 11434 -Action Allow |
| Linux (ufw) | sudo ufw allow from 192.168.1.0/24 to any port 11434 proto tcp |
| Linux (firewalld) | sudo firewall-cmd --permanent --add-port=11434/tcp then sudo firewall-cmd --reload |
| macOS | System Settings → Network → Firewall → Options, then allow incoming connections for Ollama (or answer Yes to the prompt on first launch) |
Scope the rule to your subnet where you can, as in the ufw example, rather than allowing the world.
The security implications, plainly
The Ollama API has no authentication, no API keys, and no TLS. Binding to 0.0.0.0 gives everyone who can route to that address full control: run inference, read the model list, pull new models, delete existing ones. Internet-exposed Ollama instances get found by scanners quickly, because 11434 is a well-known port.
Safer options, roughly in order of effort:
- SSH tunnel — leave the bind at loopback and forward it:
ssh -L 11434:127.0.0.1:11434 user@server. Nothing is exposed; the client talks to its own localhost. - Overlay network — Tailscale, WireGuard or similar. Bind to the overlay interface’s IP so only devices on your tailnet can connect.
- Reverse proxy — Caddy or nginx in front, terminating TLS and enforcing basic auth or a bearer token, with Ollama itself still on loopback.
If you are weighing a shared home-lab server against paying per token, the self-hosting vs API break-even calculator puts numbers on the trade-off, and the VRAM calculator tells you whether the box you want to share can actually hold the model.
Diagnosing a Port Conflict
The symptom is a startup failure that names the address, something close to:
Error: listen tcp 127.0.0.1:11434: bind: address already in useFind the owner of the port:
# Linux
sudo ss -tlnp | grep 11434
# macOS
lsof -nP -iTCP:11434 -sTCP:LISTEN
# Windows — get the PID, then name it
netstat -ano | findstr :11434
tasklist /FI "PID eq 12345"In practice the culprit is almost always Ollama itself, running twice. Common versions of that:
- The desktop app is already running in the tray or menu bar and you typed
ollama servein a terminal. The app’s server is fine — just use it. - On Linux, the systemd service is active and you ran
ollama servemanually. Stop one:sudo systemctl stop ollama. - A Docker container published
-p 11434:11434and holds the host port. Check withdocker ps.
If it is genuinely another application, move Ollama instead of fighting it — pick a free high port such as 127.0.0.1:11435 and set OLLAMA_HOST as described above. Remember to update every client’s base URL, including any OpenAI-compatible SDK config.
Docker and WSL
Inside the official container the server binds to 0.0.0.0:11434 already, so you only choose the host mapping: docker run -d -p 127.0.0.1:11434:11434 --name ollama ollama/ollama keeps it local, while -p 11434:11434 exposes it on all host interfaces. To move the host-side port, change the left number only — -p 11435:11434 — and leave the container’s internal port alone.
From WSL2 to an Ollama running on the Windows host, localhost does not always resolve to the host. Bind Windows-side Ollama to 0.0.0.0:11434, allow the port in Windows Defender Firewall, and connect from WSL using the host IP from /etc/resolv.conf or the mirrored-networking address, depending on your WSL configuration.
Frequently asked questions
Is there an OLLAMA_PORT environment variable?
No. Port and bind address are both set through OLLAMA_HOST, written as host:port. Setting OLLAMA_PORT has no effect — Ollama ignores it and keeps using 11434, which is why the change appears to silently fail.
I set OLLAMA_HOST to 0.0.0.0 but remote machines still cannot connect. Why?
Check the three layers in order. Confirm the server is actually bound to 0.0.0.0 and not 127.0.0.1 using ss, lsof or netstat; confirm the host firewall allows inbound TCP on the port; and confirm the client is using the host’s LAN IP, not localhost. The most common single cause is not fully restarting the Ollama process after setting the variable.
Does changing the port break the ollama CLI?
It can. The CLI reads the same OLLAMA_HOST variable to decide where to connect, so if the server moved but your shell has not, commands like ollama list fail with a connection error. Set the variable in your shell profile too, or prefix individual commands with it.
Can I run two Ollama instances on different ports?
Yes — start each with a different OLLAMA_HOST. They will share the same model directory unless you also give each its own OLLAMA_MODELS path. Be aware that both instances load weights into the same GPU, so two large models running at once will contend for VRAM; the VRAM requirements by model reference shows how much headroom you actually have.
What base URL do OpenAI-compatible clients need?
Point the SDK’s base URL at http://localhost:11434/v1 (adjusting host and port if you changed them). Most clients also require an API key field to be non-empty even though Ollama ignores it, so pass any placeholder string such as ollama.
Is it safe to expose port 11434 to the internet?
No. There is no built-in authentication or encryption, and the exposed API includes model pull and delete. If you need remote access, use an SSH tunnel or a private overlay network, or place an authenticating reverse proxy with TLS in front of it. If remote access is the main requirement, compare the running cost against hosted inference with the API cost calculator before building the plumbing.
Quick Reference
| Task | Action |
|---|---|
| Default port | 11434 on 127.0.0.1, HTTP |
| Change port | OLLAMA_HOST=127.0.0.1:11435 |
| Expose to LAN | OLLAMA_HOST=0.0.0.0:11434 + firewall rule |
| Persist on Linux | systemctl edit ollama.service → Environment="OLLAMA_HOST=…" |
| Persist on macOS | launchctl setenv OLLAMA_HOST "…", re-applied at login |
| Persist on Windows | User environment variable, then quit and relaunch from the tray |
| Health check | curl http://127.0.0.1:11434 |
With the port sorted, the next question is usually which model to put behind it — the best local models for Ollama covers the current options by hardware tier.

