Run Ollama In The Menu Bar On macOS With Custom Host Bindings

By default ollama runs on the localhost IP address of 127.0.0.1. But if you want to host it on macOS somewhere else, it requires a system-wide environment variable change. The developers of ollama recommend running this command, and then relaunching ollama:

launchctl setenv OLLAMA_HOST "0.0.0.0"

This works great! If you want to run this automatically at startup you can use a small AppleScript to create an application, and then add that application to your Login Items.

First, open Script Editor and paste the following code:

do shell script "launchctl setenv OLLAMA_HOST \"0.0.0.0\""
tell application "Ollama" to run

This will bind all IP addresses to ollama and then launch it. Obviously, you can bind any specific IP address you like.

Next, in the File menu use the Export command to create an Application that is signed to run locally. Quit Script Editor and then put the new application in your Applications folder.

Finally, search for “Login Items” in System Settings. Remove any existing Ollama application from the list, and add your application.

Now when you restart and sign in, your application will launch, set the environment variable for the host binding, launch Ollama, and quit.

#YOUREWELCOME #Apple #macOS #code #tech #ai

Mar 2

About Non Sequiturs

Non Sequiturs is the personal blog of Michael Argentini.

I'm a software developer and Managing Partner for Fynydd and Blue Sequoyah Technologies, the project lead for Coursabi, and Āthepedia founder. I also have several nerdy open source projects on Github.

I'd describe myself as an Oxford comma advocate, autodidact, aspiring polymath, and boffin, with a mechanical keyboard addiction. You can also find me on Mastodon.

Michael Argentini

Copyright © 2024 Michael Argentini. All rights reserved.