Local apps connect to Ollama at a host and port chosen when the server starts. On Windows 11 and Ubuntu Server 26.04 with systemd, an Ollama server environment variable such as OLLAMA_HOST changes where that server listens after a restart.
The Windows app inherits user variables from your signed-in account. The systemd service reads its environment from the unit and its drop-ins.
Ollama defaults to port 11434 on the same computer. A different port avoids a conflict, and keeping 127.0.0.1 limits connections to local apps. Clients that use the old port need the new URL after the restart.
Steps to set Ollama server environment variables on Windows 11 and Ubuntu Server 26.04 with systemd:
Choose the section that matches how Ollama starts. For the macOS desktop app, see Ollama's launchctl instructions. The macOS procedure is unverified here.
Windows 11 desktop app
Quitting Ollama interrupts any requests it is serving. The loopback example assumes the app's network exposure setting is off and port 11435 is available.
- Open the hidden icons menu in the Windows taskbar.

- Right-click the Ollama tray icon.

- Select Quit Ollama.

- Open Edit environment variables for your account from Windows Search.

- Select New under User variables.
If OLLAMA_HOST already appears in User variables, keep its current value for recovery and use Edit on that row.
- Enter OLLAMA_HOST in Variable name.

- Enter 127.0.0.1:11435 in Variable value.

- Select OK in the variable dialog.

- Select OK in Environment Variables to save the user variable.

- Open Ollama from the Start menu.
If Ollama cannot start on the new port, restore the previous user variable or remove the one you added and relaunch the app.
- Confirm the Ollama API returns its version at the new address from PowerShell.
Invoke-RestMethod -Uri 'http://127.0.0.1:11435/api/version'
A version in the reply confirms the API answers at the new URL. The latest Listening on entry in %LOCALAPPDATA%\Ollama\server.log shows the address the server bound.
Ubuntu Server 26.04 systemd service
Restarting ollama.service interrupts active requests. Port 11435 must be free before the restart, and the drop-in command needs systemd 256 or later.
- Inspect the active unit and its drop-ins for an existing OLLAMA_HOST assignment.
systemctl cat ollama.serviceContinue only if the output shows no OLLAMA_HOST assignment and /etc/systemd/system/ollama.service.d/override.conf is absent. If you find any assignment or that file already exists, stop before running the edit. The block would overwrite the existing file, and an assignment in another drop-in could override the new value.
If Ollama fails to start after the change, remove the override.conf created by the edit, reload systemd and restart Ollama to restore the previous configuration.
- Refresh sudo authentication for your current terminal.
sudo -v
- Write the loopback address into the ollama.service drop-in.
sudo -n /usr/bin/systemctl edit --stdin --no-reload ollama.service <<'EOF_DROP_IN' [Service] Environment="OLLAMA_HOST=127.0.0.1:11435" EOF_DROP_IN
systemctl edit writes /etc/systemd/system/ollama.service.d/override.conf. The --stdin option reads the block from the shell. --no-reload defers systemd's reload to the next step.
- Reload systemd's unit configuration.
sudo -n /usr/bin/systemctl daemon-reload
- Restart the Ollama service.
sudo -n /usr/bin/systemctl restart ollama.service
- Confirm the Ollama API returns its version at the new address.
curl --fail --silent --show-error --noproxy '*' http://127.0.0.1:11435/api/version
The response contains a version value. If the endpoint fails to answer, check the latest Listening on message in the Ollama service journal for the actual bind address.