Skip to content

fix: add OLLAMA_BASE_URL support to backend config#605

Open
shamil2 wants to merge 1 commit intoMODSetter:mainfrom
shamil2:fix/ollama-connection-refused
Open

fix: add OLLAMA_BASE_URL support to backend config#605
shamil2 wants to merge 1 commit intoMODSetter:mainfrom
shamil2:fix/ollama-connection-refused

Conversation

@shamil2
Copy link
Copy Markdown

@shamil2 shamil2 commented Dec 20, 2025

Fixes #587. Adds support for OLLAMA_BASE_URL environment variable to allow connection to external Ollama instances for embeddings, which fixes connection refused errors during document and YouTube video uploads in Docker.

High-level PR Summary

This PR adds support for the OLLAMA_BASE_URL environment variable to enable connections to external Ollama instances for embeddings. This resolves connection refused errors that occur during document and YouTube video uploads when running in Docker environments by allowing users to specify a custom Ollama endpoint (e.g., http://host.docker.internal:11434).

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/.env.example
2 surfsense_backend/app/config/__init__.py

Need help? Join our Discord

Analyze latest changes

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 20, 2025

Someone is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 48ea41a..3772901

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (2)

surfsense_backend/.env.example
surfsense_backend/app/config/__init__.py

@MODSetter
Copy link
Copy Markdown
Owner

MODSetter commented Dec 20, 2025

@AnishSarkar22 Can you test if it fixes the original issue. IMO I think we should be storing this in db and passing this var on runtime. Can you try that.

@shamil2 Can you raise this PR for 'dev' branch.

@AnishSarkar22
Copy link
Copy Markdown
Contributor

Sure I will test it and confirm

@AnishSarkar22
Copy link
Copy Markdown
Contributor

@MODSetter Tested this locally but the solution by @shamil2 does not fix the original issue. Chonkie doesn't have native Ollama support, so it crashes with TypeError: SentenceTransformer.__init__() got an unexpected keyword argument 'base_url'.

Yes we need a DB-based solution similar to how LLM configs work. Should I implement an Embedding Configuration UI/table that stores the base_url (and potentially model name, dimension) in the database?

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 3772901..3772901

✨ No files to analyze

deptrai added a commit to deptrai/nowing that referenced this pull request Apr 14, 2026
…ith bug fixes

PR MODSetter#893 — fix: BookStack + Obsidian missing from periodic scheduler
- Add index_bookstack_pages_task and index_obsidian_vault_task to
  schedule_checker_task.py imports and task_map

PR MODSetter#894 — feat: BookStack shelf exclusion filter
- bookstack_connector.py: get_all_shelves(), build_book_to_shelf_map()
  returning dict[int, set[int]] (fixes book-in-multiple-shelves edge case)
  get_all_pages/get_pages_by_date_range cache shelf map once (fixes N+1)
- search_source_connectors_routes.py: POST /bookstack/shelves endpoint
- bookstack_indexer.py: pass BOOKSTACK_EXCLUDED_SHELF_IDS to indexer
- bookstack-connect-form.tsx + bookstack-config.tsx: shelf picker UI
  with loading guard to prevent race condition on rapid clicks
- connectors-api.service.ts: listBookStackShelves() API method

PR MODSetter#605 — fix: OLLAMA_BASE_URL support for external Ollama embeddings
- config/__init__.py: add OLLAMA_BASE_URL env var; only inject base_url
  into embedding_kwargs when EMBEDDING_MODEL starts with "ollama://"
  (fixes original PR's bug: was unconditionally injected for all providers)
- .env.example: document OLLAMA_BASE_URL with usage notes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
deptrai added a commit to deptrai/nowing that referenced this pull request Apr 14, 2026
…ith bug fixes

PR MODSetter#893 — fix: BookStack + Obsidian missing from periodic scheduler
- Add index_bookstack_pages_task and index_obsidian_vault_task to
  schedule_checker_task.py imports and task_map

PR MODSetter#894 — feat: BookStack shelf exclusion filter
- bookstack_connector.py: get_all_shelves(), build_book_to_shelf_map()
  returning dict[int, set[int]] (fixes book-in-multiple-shelves edge case)
  get_all_pages/get_pages_by_date_range cache shelf map once (fixes N+1)
- search_source_connectors_routes.py: POST /bookstack/shelves endpoint
- bookstack_indexer.py: pass BOOKSTACK_EXCLUDED_SHELF_IDS to indexer
- bookstack-connect-form.tsx + bookstack-config.tsx: shelf picker UI
  with loading guard to prevent race condition on rapid clicks
- connectors-api.service.ts: listBookStackShelves() API method

PR MODSetter#605 — fix: OLLAMA_BASE_URL support for external Ollama embeddings
- config/__init__.py: add OLLAMA_BASE_URL env var; only inject base_url
  into embedding_kwargs when EMBEDDING_MODEL starts with "ollama://"
  (fixes original PR's bug: was unconditionally injected for all providers)
- .env.example: document OLLAMA_BASE_URL with usage notes

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

[BUG] Ollama, connection refused

3 participants