Ollama
Ollama runs large language models locally. This page covers enabling LAN access and cross-origin (CORS) access to Ollama on macOS, Windows, and Linux.
Configuration#
Ollama uses environment variables to control its bind address and allowed CORS origins. Set the variables for your platform, open the firewall port if needed, then verify.
Environment variables#
Ollama reads these environment variables:
Set OLLAMA_HOST=0.0.0.0:11434 to allow LAN access. Set OLLAMA_ORIGINS=* to allow all cross-origin requests.
OLLAMA_ORIGINS accepts these values:
Set environment variables on macOS#
On macOS, Ollama runs as a GUI app managed by launchd.
-
Set the variables with
launchctl: -
Quit Ollama from the menu bar and relaunch it.
Set environment variables on Windows#
-
Set user environment variables in PowerShell:
-
Quit Ollama from the Start menu and relaunch it.
Set environment variables on Linux#
On Linux, Ollama runs as a systemd service. Run these steps in a root shell:
-
Edit the service configuration:
-
Add the following content:
-
Reload the configuration and restart the service:
Allow the port in Windows Firewall#
Add an inbound rule for TCP port 11434:
Allow the port in Linux firewall#
Allow TCP port 11434 in the firewall you use:
Verify the configuration#
Request the version endpoint. A version number in the response means the service is reachable.
macOS and Linux:
Windows:
Troubleshooting#
These are common cases where environment variables do not take effect on macOS.
Environment variables in zshrc have no effect on macOS#
Cause: Ollama is started by launchd and does not read ~/.zshrc.
Fix: set the variables with launchctl setenv instead. See Set environment variables on macOS.
Settings are lost after restarting macOS#
Cause: settings made with launchctl setenv do not persist across reboots.
Fix: use either method to persist them:
- Run
ollama servemanually. - Create a LaunchAgent plist.