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:

  1. Download Ollama from ollama.com.
  2. Open the downloaded .dmg, drag Ollama to Applications, and open it.
  3. 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:

Bash
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.

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:

Bash
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:

Bash
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):

Bash
launchctl unload ~/Library/LaunchAgents/com.ollama.origins.plist
rm ~/Library/LaunchAgents/com.ollama.origins.plist

Which value to use?

ValueDescriptionWhen 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 on 127.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:

  1. Find the Ollama icon in the menu bar (top-right of your screen).
  2. Click the icon → choose Quit Ollama.
  3. 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:

Bash
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

  1. Open the Cognito extension in Chrome.
  2. Go to Ollama / provider settings and select Ollama.
  3. Use Refresh or Check connection in the extension. It should show a successful connection and list your models.
  4. Start a chat and choose an Ollama model.

Quick reference

MethodPersists across reboots?
A — Terminal commandNo — resets on reboot
B — Launch AgentYes — 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 getenv shows nothing: The variable isn't set in the GUI environment. Try running launchctl setenv OLLAMA_ORIGINS "*" again, or check that the Launch Agent file was created correctly.
  • echo $OLLAMA_ORIGINS shows * but extension still can't connect: echo shows your shell's variable, which is separate from the GUI/app environment. Use launchctl getenv OLLAMA_ORIGINS to check what Ollama actually sees.
  • Permission error: launchctl setenv doesn't need admin rights — run Terminal as your normal user.
  • Ollama not in PATH: If you installed via the app, ollama is 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.