Ollama setup on macOS
Follow these steps to allow the Cognito Chrome extension to connect to Ollama on your Mac.
1. Install Ollama
If you haven't already:
- Download Ollama from ollama.com.
- Open the downloaded
.dmg, drag Ollama to Applications, and open it. - Optionally pull a model from the app or from Terminal:
ollama pull llama3.2.
2. Set OLLAMA_ORIGINS
Ollama blocks connections from browser extensions by default. You need to tell Ollama which origins (websites / extensions) are allowed to connect. This is done by setting an environment variable called OLLAMA_ORIGINS.
There are two ways to do this on macOS. Read both and pick the one that works best for you.
Method A: Terminal command (quick, but resets on reboot)
Best for: Trying things out, or if you don't mind running a command after each reboot.
Open Terminal (press Cmd + Space, type "Terminal", press Enter) and run:
launchctl setenv OLLAMA_ORIGINS "*"
That's it. The value is now set for the current session.
Advantages:
- Very quick — one command and you're done.
- Easy to remember and type.
Disadvantages:
- The setting is lost when you restart or shut down your Mac. You'll need to run the command again after every reboot.
- If Ollama auto-starts at login, it may start before you open Terminal, so it won't see the value until you quit and reopen Ollama.
Method B: Launch Agent (automatic, persists across reboots) — Recommended
Best for: A permanent "set it and forget it" setup. Works even if you never open Terminal after rebooting.
A Launch Agent is a small file that tells macOS to run a command automatically every time you log in — before apps like Ollama start. This ensures Ollama always sees the correct OLLAMA_ORIGINS value.
Step 1 — Create the Launch Agent file
Open Terminal and paste this entire block, then press Enter:
mkdir -p ~/Library/LaunchAgents
cat > ~/Library/LaunchAgents/com.ollama.origins.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ollama.origins</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>setenv</string>
<string>OLLAMA_ORIGINS</string>
<string>*</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
Step 2 — Activate it
Still in Terminal, run:
launchctl load ~/Library/LaunchAgents/com.ollama.origins.plist
This registers the agent. From now on, macOS will run launchctl setenv OLLAMA_ORIGINS "*" automatically every time you log in.
Advantages:
- Persists across reboots — you never need to touch it again.
- Runs automatically at login, before Ollama starts, so Ollama always picks up the value.
- No need to open Terminal after restarting your Mac.
Disadvantages:
- Slightly more setup the first time (copy-pasting the block above).
- If you ever want to change or remove the setting, you need to edit or delete the file (see "How to remove" below).
How to remove the Launch Agent (if needed):
launchctl unload ~/Library/LaunchAgents/com.ollama.origins.plist
rm ~/Library/LaunchAgents/com.ollama.origins.plist
Which value to use?
| Value | Description | When to use |
|---|---|---|
* | Allow all origins | Recommended for most users. Simple and safe — Ollama only listens locally. |
chrome-extension://bcejicipnpgpcbmnafmnlgmpdingjkdk | Allow only the Cognito extension | Use if you want tighter access control. Update the ID if it changes. |
Using
*is recommended. Ollama only listens on127.0.0.1(your machine), so it is not exposed to the internet.
To use the extension-only value, replace * with chrome-extension://bcejicipnpgpcbmnafmnlgmpdingjkdk in the commands above. If you use a different build (e.g. unpacked), check the Cognito extension → Ollama panel for your extension's ID.
3. Restart Ollama
After setting OLLAMA_ORIGINS for the first time, you need to quit and reopen Ollama so it picks up the new value:
- Find the Ollama icon in the menu bar (top-right of your screen).
- Click the icon → choose Quit Ollama.
- Open Ollama again from Applications or Spotlight (Cmd + Space → type "Ollama" → Enter).
You only need to do this once. After a reboot, Ollama will start with the correct value automatically (if you used Method B).
4. Verify the setting
To confirm OLLAMA_ORIGINS is set correctly, open Terminal and run:
launchctl getenv OLLAMA_ORIGINS
You should see * (or your chosen extension origin) printed. If it shows nothing, the variable isn't set yet — go back to Step 2.
5. Check that it works
- Open the Cognito extension in Chrome.
- Go to Ollama / provider settings and select Ollama.
- Use Refresh or Check connection in the extension. It should show a successful connection and list your models.
- Start a chat and choose an Ollama model.
Quick reference
| Method | Persists across reboots? |
|---|---|
| A — Terminal command | No — resets on reboot |
| B — Launch Agent | Yes — automatic at login |
Troubleshooting
- Connection still fails after setting OLLAMA_ORIGINS: Make sure you quit and reopened Ollama after setting the variable. New env vars only apply to new processes.
launchctl getenvshows nothing: The variable isn't set in the GUI environment. Try runninglaunchctl setenv OLLAMA_ORIGINS "*"again, or check that the Launch Agent file was created correctly.echo $OLLAMA_ORIGINSshows*but extension still can't connect:echoshows your shell's variable, which is separate from the GUI/app environment. Uselaunchctl getenv OLLAMA_ORIGINSto check what Ollama actually sees.- Permission error:
launchctl setenvdoesn't need admin rights — run Terminal as your normal user. - Ollama not in PATH: If you installed via the app,
ollamais usually in PATH. Otherwise use the full path (e.g./Applications/Ollama.app/Contents/Resources/ollama).
After setup, pull more models with ollama pull <model> or from the Cognito extension's Ollama panel.