Why browsers block Ollama by default and when to open an origin
A team that wants a web app or browser extension to call a shared Ollama server often hits a cross-origin error before any model replies. Browsers enforce cross-origin rules: a page loaded from one origin, such as an internal portal, cannot read responses from another origin, such as a server on port 11434, unless that server explicitly allows it. Ollama works the same way. The server must name each origin it trusts, and OLLAMA_ORIGINS is the setting that does this. Treat the setting as a browser control. Any client that is not a browser can send any Origin header it likes, and the local API does not require authentication, so the origin list does not decide who may call the server.
Open an origin when a known web app or browser extension must run in users' browsers and call the server directly, and when your team controls where that front end is hosted. Add the exact origin of that app, including scheme and port, and nothing broader. Before you write any entries, confirm the accepted format, the matching rules and the default behavior in the Ollama FAQ, and check them against the version you run. Keep the list in your configuration review so every addition has an owner and a reason.
A proxy or gateway is the better home for browser access when many users need it, when each user needs their own identity, or when you need usage limits and logs. In that design, the web app calls its own backend, and the backend calls Ollama over a server-side connection, so browsers never reach the Ollama port and the origin list can stay empty. Choose this path early if the app will serve staff across several teams, because the origin list will otherwise grow with every new front end. Ask the owner of each web app which path they plan to use and record the answer before any origin is added.
How a browser request reaches Ollama and where the origin check happens
The request starts in a web app or browser extension running in the user's browser on their device. Before the request leaves the browser, the browser compares the page's origin with the origins the Ollama server allows, so a cross-origin call can be blocked before it reaches the server. The server host is a separate trust boundary, and the Ollama API on port 11434 does not authenticate callers. Check that a reverse proxy, if you add one, sits on the server side of that boundary and is the place where access control is enforced.
Browser origin checks sit on the user device before any request reaches the Ollama server.
OLLAMA_ORIGINS values and when each fits
This table compares the main OLLAMA_ORIGINS patterns, from the default local-only behavior to wildcard values. For each pattern, read the typical use, the exposure it creates on a networked server and what to verify before the change goes live. The main takeaway is that origin settings only control which web pages a browser will call, and they do not authenticate any caller.
| Value pattern | Typical use | Exposure on a networked server | What to verify |
|---|---|---|---|
| No change (default) | Tools on the same machine that call the API directly, without a browser page in between | Lowest browser exposure, since pages from other origins are blocked by default | Confirm browser calls from another origin are refused and the server still binds to 127.0.0.1 |
| Exact origin for a named web app | One internal chat or admin page served from a known address | Limited to one page origin, but any user who can load that page can call the API | The entry matches the page's host name exactly, with no extra characters or trailing slash |
| Scheme and port specific entries | An app served over HTTPS on a non-default port, or a local HTTP development server | HTTP and HTTPS versions of the same host are separate origins, so each entry widens access on its own | Entries match the scheme and port the browser shows, and development-only ports are removed on shared servers |
| Browser extension origins | A locally installed extension that sends requests to Ollama | Limited to that extension, but every user who installs the same build gains access | The extension origin matches the installed build, and the entry is reviewed after each extension update |
| Wildcard value | Short tests on a single workstation | Any web page a user opens in a browser that can reach the server can send requests to it, and the API has no built-in authentication | Confirm the exact wildcard syntax and behavior in the Ollama FAQ before use, and never set it on a host reachable from a network |
| Any value on a server reachable from the network | Shared Ollama servers used by several teams or applications | Origin settings do not stop non-browser clients such as scripts, so the API stays open to them | Authentication and network controls are in place in front of the server before the origin list is widened |
How to set OLLAMA_ORIGINS and confirm the change on a server
This sequence takes a shared Ollama host from an undocumented browser allowlist to a tested configuration, where approved origins succeed, unlisted origins are refused, and the change is recorded for the next reviewer.
Build the approved origin list with owners
Before touching the server, the platform owner and the application owners agree on a short list of exact browser origins, such as scheme, host and port for each web app or extension that must call the API from a browser. Each entry gets a named owner, a business reason and a review date recorded in the change ticket. Wildcards and broad patterns are rejected at this stage, because a single broad entry can expose the API to any site a user visits. The output is a reviewed list that the change record can cite, and that someone can explain line by line.
Set the variable in the service definition
The platform engineer adds OLLAMA_ORIGINS with the comma-separated approved list to the place the host actually reads its environment. On a systemd host this is usually a drop-in override for the Ollama unit, created with a systemctl edit command, that sets the variable in an Environment line. In a container, it belongs in the compose file or run command, and on Windows it is set in the environment for the service or the account that runs Ollama. Confirm the exact mechanism for your install method and version in the official FAQ before editing, because the file name and precedence differ between installs. Keep the change in version control so the list is reviewable.
Restart the service and confirm it loaded
The operator reloads the service manager configuration and restarts Ollama so the new environment takes effect. A restart on a running shared server interrupts active requests, so schedule it with the users of the host in mind. Confirm that the service came back up and is listening on the expected address and port, which is 127.0.0.1 on port 11434 unless OLLAMA_HOST was changed. A service that fails to start usually points to a quoting or syntax error in the override, which the service manager log will show.
Check the server logs and effective settings
The operator reads the Ollama server log from the same service manager or container runtime and looks for the startup configuration output, which lists the environment values the server actually parsed. The origin list should appear exactly as written, with no stray spaces, missing commas or leftover wildcard entries. If the log does not show the setting, the variable is not reaching the process, and the reader should go back to the service definition rather than assume the change applied. Save a copy of this startup output with the change record.
Test an approved origin succeeds
From a browser or a test page served from one of the approved origins, the tester sends a cross-origin request to the local API and checks the response headers for an Access-Control-Allow-Origin value that matches the approved origin. Use the same web app or extension the business owner will actually use, since a test harness can behave differently from a real client. A successful response with the matching header shows the allowlist works for that origin. Record the origin, the date, the tester and the result in the change record.
Test an unlisted origin is refused
From a page served from an origin that is not on the list, which can be a scratch page on a different port or a separate test host, the tester repeats the same cross-origin request. The response should not include an Access-Control-Allow-Origin header that grants that origin, so the browser blocks the page from reading the reply. Include at least one origin that differs only in port or subdomain from an approved entry, because those near-miss cases are where lists tend to fail. Log the result for each case in the same record as the approved-origin tests.
Retest after every change and file the evidence
Any change to the origin list, the host, the proxy in front of Ollama or the Ollama version repeats the startup check and both browser tests. The platform owner stores the reviewed list, the service definition, the startup output and the test results together so an auditor or security reviewer can trace who approved each origin and when it was verified. Because the exact behavior can change between Ollama releases, confirm the mechanism against the release you run rather than relying on an earlier procedure. This retest is a recurring task, not a one-time setup step.
Why wildcard origins on a networked server are a risk
Once Ollama listens beyond localhost, the browser becomes a path to the API for any page a user opens. The cards below explain how origin settings interact with the missing authentication, the extra callers that appear on shared machines and the network controls that have to sit alongside them.
Any visited website can call the API
A browser sends requests to localhost or a private address on behalf of whatever page the user has open. If OLLAMA_ORIGINS allows *, a page on any site a user visits can send prompts to the Ollama API and read the responses. Check that the server is not reachable from networks where untrusted pages are the only thing separating a user from it, and test with a page from an origin you do not control.
Origins do not authenticate callers
The local API does not require authentication, so the origin list only tells the browser which pages may read responses. Any client that does not send a browser Origin header, such as curl or a script on another host, ignores the list entirely. Treat origin settings as a usability control, and put authentication in front of the server before it accepts outside connections.
Extensions and shared machines add callers
Browser extensions run with access to pages and can make requests the user never sees, and every person on a shared workstation shares the same browser profile options. Each extension or added web app is a new caller that the origin list now trusts. Review which extensions and internal web apps are allowed, and remove entries for tools that no longer need access.
Browsers can reach internal hosts
A user's browser sits inside the corporate network, so a malicious page can ask that browser to contact internal addresses, a technique often called DNS rebinding or cross-site request forgery against internal services. An Ollama server on a private address becomes reachable this way even when it is not exposed to the internet. Use firewall rules that allow only known client subnets and a reverse proxy with authentication in front of the port.
Logs show unexpected callers
The server logs record requests, including the paths and client addresses that reach the API, so unusual browser-driven traffic appears there. Without a proxy in front, the log entries show only the connecting address, which may be the proxy itself. Review logs after any origin change for requests from addresses or paths you did not expect, and forward them to your central logging system.
Changes drift between servers
An origin list set by hand on one server is easy to forget when a second server or a container image is built. Settings in the service unit, container environment and proxy configuration can disagree, so a server may accept browser calls that the others reject. Keep the value in version-controlled configuration, deploy it the same way everywhere, and confirm the effective setting on each host after every change.
Browser origins for local tools, internal web apps and extensions
A developer running a browser front end on the same machine as Ollama usually calls from a page served on another local port. The browser treats that page as a different origin, so the request is blocked unless the page's origin is listed in OLLAMA_ORIGINS`. Because the server binds to 127.0.0.1 by default, the exposure stays on this machine, which keeps the risk low as long as the list stays narrow.
- Match the exact origin: Include scheme, host and port, for example ` then restart the server so the change takes effect.
- Resist wildcards during debugging: A wildcard added to clear an error often survives into later configuration without anyone deciding to keep it.
- Confirm the local bind address: Check that the server still listens on 127.0.0.1 so the allowed origin cannot be reached from other machines.
- Test the preflight path: Send a request from the UI and watch the browser console for CORS errors after each change.
- Test a second local app: Load another page on a different local port and confirm it is still blocked.
Check that the UI works, that unlisted local apps fail, and that the server log shows only the requests you expect.
When an internal web app is served from another host, the browser origin is that host's address, so the Ollama server must be reachable from the user's network. That usually means changing OLLAMA_HOST from its localhost default, which widens reachability for an API that has no built-in authentication. Adding the app's origin controls what browsers may call, but it does not control who may call the server, and non-browser clients ignore it entirely. The Ollama FAQ describes exposing the server through a proxy, which is the usual place to add authentication first.
- Use the origin users actually type: Enter the internal DNS name and port the app is served on, and match it exactly.
- Bind to a private interface: Set
OLLAMA_HOSTto a private address only when a firewall limits sources to the app host. - Do not treat CORS as access control: Scripts,
curland other services can reach the API without any browser checks. - Test from inside and outside: Requests from the app host should succeed, while requests from unlisted hosts should fail in the browser and be blocked at the network layer.
- Plan the gateway early: If several apps, SSO or per-user limits are needed, route browser traffic through a gateway that authenticates requests and list only that gateway as an origin.
Confirm the firewall rules and origin list together, because either one alone leaves a gap.
Browser extensions run under their own origin, which uses an extension scheme and an identifier assigned by the browser rather than a web address. Background scripts and content scripts can send requests with different origin values, so the origin your extension sends may not match what its store page or documentation suggests. Verify the origin from the request itself, because a guess based on the extension's name can leave a broken entry or an over-broad one.
- Read the origin from the request: Inspect the request headers or the extension's console and record the exact origin string.
- Expect identifiers to change: Reinstalling, loading an unpacked build or receiving a store update can change the identifier and break a hard-coded entry.
- List one identifier per approved build: Avoid scheme-wide patterns, since they allow any extension using that scheme.
- Review host permissions: An extension with access to the Ollama port can reach the API beyond what its interface needs, so review its declared permissions.
- Use a gateway for managed fleets: When many users run the extension, or each user needs their own key or budget, authorize extensions at a gateway instead of maintaining a growing origin list.
Check the origin string from a clean install of the approved build, then repeat the check after every update.
On a shared server, every listed origin is trusted for every user. Any script running on a listed origin, in any user's browser, can send prompts and read responses, and the server has no per-user identity to separate one person's requests from another's. A single compromised page or extension on a listed origin can therefore reach the shared model. Keep the origin list short and reviewed, and move browser traffic behind a gateway that adds authentication, per-user keys and logs, as described in the Ollama API authentication documentation.
- Treat the list as a controlled change: Record who requested each origin, why, and when, and review the list on a regular schedule.
- Assume full trust for listed origins: Anything running on an approved origin inherits access to every model the server offers.
- Test an unlisted origin: From a page on an origin that is not in the list, confirm the browser blocks the call and that no allow header appears in the response.
- Check what the logs record: Confirm which fields the server logs for each request before relying on logs to attribute usage to a person or team.
- Set clear gateway triggers: Move to a gateway when more than one team needs browser access, when users need separate identity or budgets, or when audits must name the user behind a request.
Re-run the unlisted-origin test after every change to the list or the server configuration.
What to confirm about origin matching and browser behavior
Setting OLLAMA_ORIGINS is only part of the job. The checks below cover how the server compares origins, how browsers and proxies change the headers it sees, and whether the release you run behaves as documented. Confirm each one in your own environment before you call a browser integration working.
Exact origin string matching
Confirm how the server compares the browser's Origin header with each entry in OLLAMA_ORIGINS. Scheme, host and port all form part of the origin, so and are different values, and a trailing slash or a missing port can cause a silent mismatch. Send a test request from the exact address your app uses, not from a similar one. Check the server logs or response headers to see which origin was accepted or refused.
Extension origins across browsers
Browser extensions send origins that look like chrome-extension:// or moz-extension:// followed by an ID that is generated per installation or per browser. The ID can differ between Chrome, Edge, Firefox and other Chromium builds, and it can change when an extension is reinstalled. Confirm the origin each browser actually sends for your extension, using the browser's developer tools on a request to the server, before you add it to the allowlist. Record the ID you tested so a later reinstall does not break the tool quietly.
Preflight methods and headers
Browsers send an OPTIONS preflight before some cross-origin requests, particularly those with JSON bodies or custom headers such as Authorization. Confirm that the preflight succeeds for every method and header your client uses, including streaming chat calls. Test with the browser, not only with curl, because curl does not send preflights and will show a working server that the browser rejects. Note any custom header the client adds and retest after each change to the client.
Reverse proxy header changes
If Nginx or another proxy sits in front of Ollama, confirm whether it passes the Origin header unchanged and whether it adds or strips Access-Control headers. A proxy that rewrites the Host header or answers preflights itself can make a correct OLLAMA_ORIGINS value look broken, or make a wider policy apply than intended. Compare responses from the proxy address and from the Ollama address on the host. Document which layer owns CORS so that a future proxy change does not duplicate or override the headers.
Ollama FAQRestarts and upgrades
Confirm where OLLAMA_ORIGINS is set for your install method, such as a systemd override, a container environment or a Windows user variable, and whether a restart or upgrade keeps it. A value set in an interactive shell is lost when the service starts at boot. After every restart or upgrade, repeat the browser test rather than assuming the setting survived. Keep the variable in the same configuration file as the rest of the server settings so reviewers can find it.
Behavior of your release
Read the release notes for the Ollama version you run and check whether CORS handling changed in that release or a later one you plan to adopt. Releases ship often, so a behavior you tested on one version may differ after an upgrade. Ask for the target version in writing and retest on a staging server before production. Keep the test results with the change record.
Ollama releasesHow to test CORS behavior after a change
Test CORS behavior with a short, written plan that runs after every change to OLLAMA_ORIGINS, and keep the plan separate from the application's own test suite so that someone other than the developer can run it. Start with a list of the origins you approved: the internal web app, any approved browser extension and any admin console. For each one, send a request from a browser context that carries that origin and confirm the response includes an Access-Control-Allow-Origin header matching it. Then do the same with a list of origins you did not approve, such as an unrelated site or a local test page, and confirm that the response does not grant them access. Record the exact origin string used, because a missing trailing slash or a wrong scheme is one of the most common reasons an approved app fails.
Next, reproduce the real application's preflight. Browsers send an OPTIONS request before cross-origin calls that use a non-simple method or custom headers, so the test should use the same HTTP method, the same Content-Type and any custom headers the app sends, such as an authorization header if your proxy adds one. A test that only sends a simple GET will pass even when the real chat request fails. Run the same checks after each Ollama upgrade, after any change to the proxy or gateway in front of the server, and after firewall rule changes, since any of these can alter which headers reach the client. Keep a dated log for each server and each Ollama version, with the origins tested, the results and the person who ran the test, so that a regression can be traced to a specific change.
These tests confirm browser behavior only. A passing CORS test does not show that the API is protected from non-browser clients such as scripts or command-line tools, which ignore CORS entirely, and it does not show that the server is reachable only from the networks you intended. Those questions belong to a separate authentication and network review, covered in the sibling topic on exposing Ollama on a network safely.
Questions teams ask about OLLAMA_ORIGINS before hiring help
Does setting OLLAMA_ORIGINS cost anything?
The setting itself carries no license fee, because Ollama is MIT licensed and running models on your own hardware is listed as unlimited on the Ollama pricing page. The cost comes from effort: inventorying which web apps and browser extensions call the server, deciding which origins to allow, changing the configuration, and testing the result. If you hire help, you pay for that scoping, testing and documentation work, which is a one-time cost for the change. Ongoing cost appears only when the origin list changes as new tools are adopted, so ask whether a quote covers future changes or only the current list.
How long does one CORS change and test cycle take?
There is no fixed duration, because the time depends on how many origins you allow and how many environments and servers need the same change. A single host with a short, known list of origins is a small task. A fleet with several environments, each with different tools and owners, takes longer because every origin needs a test and every environment needs a check after the change. Ask any provider for a timeline that is tied to a written list of origins, environments and test cases, not a general estimate.
What does our internal team need to provide before the work starts?
Four inputs make the work predictable:
- An inventory of every web app and browser extension that calls the Ollama API, including the exact origin each one uses.
- A named owner for each app or extension who can confirm it is still needed and approve its origin.
- Administrative access to the host or hosts, with the ability to edit the service environment and restart Ollama.
- A test plan that states which requests must succeed, which must be refused, and who runs the checks.
Missing inventory items are the most common reason a change is delayed, so collect them before you request a quote.
Can our own engineers set OLLAMA_ORIGINS without outside help?
Yes, for a small, known list of origins on one host. The change is an environment variable in the service configuration, followed by a restart and a few requests to confirm behavior. It becomes harder when the list is long, when several servers must match, when browser extensions use origins that change, or when the change must be documented for auditors. In those cases the main work is inventory, consistent configuration across servers and repeatable testing, which a team can also build in-house if it has the time and an owner for the process.
Why is a wildcard origin risky on a networked Ollama server?
A wildcard allows any website a user visits to send requests to the Ollama API through that user's browser. On a server bound only to localhost, the exposure is limited to users on that machine. Once the server listens on a network address through OLLAMA_HOST, any page in a user's browser can use the server's models, and the API has no built-in authentication to stop that. Keep the list of allowed origins specific, and put authentication and network controls in front of the server before exposing it to other hosts.
How do we test CORS behavior after a change?
Test both sides of the rule. For each allowed origin, confirm that a browser request from that origin succeeds, and for an origin that is not on the list, confirm that the request is refused. Repeat the checks after every restart and after any change to the host or proxy, because a proxy can add or remove headers. Record the results with the configuration version and the date so that the evidence can be reviewed later. Confirm the exact logging and test method with your own security team before relying on it.
What should a quote for this work include?
Ask for a written scope that lists the servers and environments in scope, the origins to be allowed, the expected configuration changes, the test cases for allowed and refused origins, and the evidence delivered at the end. The quote should also state what the provider needs from your team, who approves each origin, how changes after handover are handled, and whether a retest is included. DeployOpen works from a written scope agreed before work starts, so a quote follows from that document rather than from a standard price.
How DeployOpen works on this
DeployOpen treats browser access to Ollama as part of the server's exposure, not as a single setting. We scope which browser origins genuinely need access, build the OLLAMA_ORIGINS configuration in your infrastructure, and test the result from the origins that matter and from those that should be blocked.
How we scope
- We list every web app and browser extension that must call the Ollama API, with its exact origin.
- We record which origins must stay blocked and why, so the allowlist has a documented reason for each entry.
- Engagements are fixed-scope, with the origin list, deliverables and timeline agreed in writing before work starts.
- We confirm with you whether the server is reachable beyond localhost, since that changes the risk of any origin rule.
How we build
- We set OLLAMA_ORIGINS to explicit scheme, host and port values instead of wildcard entries on networked servers.
- We apply the change through the service configuration your team uses, so it survives restarts and upgrades.
- We pair origin rules with network controls, since OLLAMA_ORIGINS governs browsers and does not replace authentication.
- We document each change so reviewers can trace which origin was allowed, by whom and for which application.
How we hand over
- You receive the final origin allowlist, the configuration location and a record of the tests that were run.
- We document how to add or remove an origin, including the review step your team should follow first.
- Runbooks cover how to check the active setting in the service configuration and in the server logs after a change.
- Handover includes a short session with the people who will maintain the origin list.
How we support
- Ongoing support is available as a retainer, covering origin review requests, upgrades and configuration drift checks.
- We retest browser access after Ollama version upgrades, new applications or changes to the server's network exposure.
- Continuous testing can be added to the retainer so origin rules are checked against each new release you deploy.
- We confirm with your security team how changes are approved before any origin is added to a production server.

