Browsers block web pages from calling other origins unless the server allows it. Ollama allows localhost origins by default, but a browser app on another origin, or a browser extension, needs OLLAMA_ORIGINS set explicitly.
What you need
- Ollama installed and running
- The origin of the browser app, for example http://localhost:3000
- A way to set environment variables and restart Ollama
Step 1: Set the allowed origins
Set the environment variable OLLAMA_ORIGINS to the origins the app uses, for example OLLAMA_ORIGINS=http://localhost:3000. By default Ollama allows 127.0.0.1 and 0.0.0.0 origins; anything else must be listed.
Step 2: Restart Ollama
Quit Ollama and start it again so the new variable applies. On Linux, restart the service with sudo systemctl restart ollama. Environment changes do not affect a running server.
Step 3: Test from the browser app
Open the app and send a request to http://localhost:11434/api/tags or a chat call. A CORS error in the browser console means the origin is still not allowed; a JSON reply means it works.
Worked example: allow a local web app
The table below is a synthetic example. The variable name and default behaviour come from the Ollama FAQ; the origin is illustrative.
| Step | Value | Expected result |
|---|---|---|
| Variable | OLLAMA_ORIGINS=http://localhost:3000 | Origin allowed |
| Restart | Restart Ollama | New setting applies |
| Test | Browser fetch to /api/tags | JSON reply, no CORS error |
Expected result (UNTESTED). after restart, the browser app receives JSON from the Ollama API instead of a CORS error. This check was not run live; the variable and defaults come from the cited Ollama FAQ.
Limits
- OLLAMA_ORIGINS only affects browser CORS checks; curl and scripts are not blocked.
- The variable must be set before Ollama starts; a running server ignores it.
- Allowing every origin is convenient for testing but weakens the localhost-only default.
- The Ollama API has no authentication, so keep port 11434 off public networks.
