Skip to content

fix: respect OLLAMA_HOST env var for remote Ollama servers#82

Merged
Rishabh4275 merged 4 commits into
platinum-hill:mainfrom
rishabhvaish:fix/respect-ollama-host-env-var
Mar 2, 2026
Merged

fix: respect OLLAMA_HOST env var for remote Ollama servers#82
Rishabh4275 merged 4 commits into
platinum-hill:mainfrom
rishabhvaish:fix/respect-ollama-host-env-var

Conversation

@rishabhvaish

Copy link
Copy Markdown
Contributor

Summary

  • Fixes crash on startup when OLLAMA_HOST env var is set to a remote server address
  • Cobolt now detects OLLAMA_HOST, uses it as the connection URL, and skips spawning ollama serve locally when the host is remote
  • Provides a clear error message if the remote Ollama server is unreachable

Root Cause

When OLLAMA_HOST is set (e.g., 100.106.67.57:11434), ollama serve tries to bind to that remote IP locally, which fails with:

Error: listen tcp 100.106.67.57:11434: bind: The requested address is not valid in its context.

The existing code always tried to spawn ollama serve when the server wasn't reachable, without considering that the user may have configured a remote host.

Changes

Function What it does
resolveOllamaHost() Reads OLLAMA_HOST env var (supports both host:port and full URL formats), falls back to stored config
isRemoteOllamaHost() Checks if the host is non-local (not localhost, 127.0.0.1, ::1, 0.0.0.0)
initOllama() Skips ollama serve spawn when remote, shows clear error if remote server is unreachable

Closes #77

Test plan

  • Set OLLAMA_HOST to a remote server that is running Ollama → Cobolt should connect without spawning local server
  • Set OLLAMA_HOST to a remote server that is NOT running → Cobolt should show a clear error message about unreachable remote server
  • Unset OLLAMA_HOST → Cobolt should behave as before (start local ollama serve if needed)
  • Set OLLAMA_HOST=localhost:11434 → Should still spawn local server if not running (treated as local)

🤖 Generated with Claude Code

…te hosts

When OLLAMA_HOST is set to a remote server address, Cobolt would try
to run `ollama serve` locally, which fails because it attempts to bind
to the remote IP address. This caused a crash on startup.

Changes:
- Add resolveOllamaHost() that prioritizes OLLAMA_HOST env var over
  stored config, handling both bare host:port and full URL formats
- Add isRemoteOllamaHost() to detect non-local addresses
- Skip spawning `ollama serve` when pointing to a remote host
- Show a clear error message if the remote server is unreachable

Closes platinum-hill#77
The test CI has been broken since windows-latest migrated to Server
2025 (missing Windows SDK for node-gyp/sqlite3 native compilation)
and npm run package attempted electron-builder signing without certs.

Changes:
- Pin Windows runner to windows-2022 which has the full VS + Windows
  SDK needed for native module compilation
- Replace npm run package with npm run build (package runs
  electron-builder with signing/notarization which fails without
  certs and is unnecessary for CI test validation)
- Bump actions/checkout, setup-node, setup-python to latest major
  versions (v3→v4, v4→v5)
- Split test steps into separate named steps for easier debugging
Comment thread .github/workflows/test.yml
rishabhvaish and others added 2 commits February 25, 2026 23:49
Adds back the package step with GH_TOKEN env var as requested
in review. Replaces the standalone build step since npm run package
already includes npm run build internally.
Reviewer requested keeping the original combined "Run tests" step.
Consolidates the separate Package, Lint, Type check, and Run tests
steps back into the original single step that runs all four commands.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Rishabh4275
Rishabh4275 enabled auto-merge (squash) March 2, 2026 04:06
@Rishabh4275
Rishabh4275 disabled auto-merge March 2, 2026 04:07
@Rishabh4275
Rishabh4275 merged commit dbb6fad into platinum-hill:main Mar 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error during startup if you have OLLAMA_HOST defined

2 participants