Fosowl/agenticSeek · error · ValueError
SearxNG base URL must be provided either as an argument or v
Error message
SearxNG base URL must be provided either as an argument or via the SEARXNG_BASE_URL environment variable.
What it means
The SearxSearch tool's __init__ requires a SearxNG instance URL, taken from the base_url argument or the SEARXNG_BASE_URL environment variable. If both are missing it raises ValueError immediately at construction time, because the tool cannot function without a SearxNG endpoint.
Source
Thrown at sources/tools/searxSearch.py:27
from sources.tools.tools import Tools
class searxSearch(Tools):
def __init__(self, base_url: str = None):
"""
A tool for searching a SearxNG instance and extracting URLs and titles.
"""
super().__init__()
self.tag = "web_search"
self.name = "searxSearch"
self.description = "A tool for searching a SearxNG for web search"
self.base_url = base_url or os.getenv("SEARXNG_BASE_URL") # Requires a SearxNG base URL
self.user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"
self.paywall_keywords = [
"Member-only", "access denied", "restricted content", "404", "this page is not working"
]
if not self.base_url:
raise ValueError("SearxNG base URL must be provided either as an argument or via the SEARXNG_BASE_URL environment variable.")
def link_valid(self, link):
"""check if a link is valid."""
# TODO find a better way
if not link.startswith("http"):
return "Status: Invalid URL"
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
try:
response = requests.get(link, headers=headers, timeout=5)
status = response.status_code
if status == 200:
content = response.text.lower()
if any(keyword in content for keyword in self.paywall_keywords):
return "Status: Possible Paywall"
return "Status: OK"
elif status == 404:
return "Status: 404 Not Found"View on GitHub (pinned to ae57a23577)
Solutions
- Set the env var: export SEARXNG_BASE_URL=https://your-searxng-instance (and ensure .env is loaded before constructing the tool)
- Pass base_url explicitly: SearxSearch(base_url='https://searx.example.com')
- Verify the variable name spelling and that it is visible to the process (print os.getenv in the same interpreter)
- Stand up or reach a SearxNG instance (public instance or docker run searxng) if you have none
Example fix
// before
search = SearxSearch() # ValueError: no base URL
// after
import os
from dotenv import load_dotenv
load_dotenv()
assert os.getenv('SEARXNG_BASE_URL'), 'Set SEARXNG_BASE_URL'
search = SearxSearch() Defensive patterns
Strategy: validation
Validate before calling
import os
from dotenv import load_dotenv
load_dotenv()
if not (os.getenv('SEARXNG_BASE_URL') or '').startswith('http'):
raise SystemExit('Set SEARXNG_BASE_URL (e.g. https://searx.example.com) before constructing SearxSearch') Try / catch
try:
search = SearxSearch()
except ValueError as e:
logger.error('SearxNG not configured: %s', e)
raise SystemExit('Provide base_url or SEARXNG_BASE_URL env var') from e Prevention
- Add SEARXNG_BASE_URL to .env and load it before tool construction
- Construct search tools in a startup step that fails fast with a clear config check
- Validate the URL with a health ping (/search?q=test) at boot
- Keep env var names consistent across deployment scripts and containers
When it happens
Trigger: Instantiating SearxSearch() (or whatever wraps it) with no base_url argument while SEARXNG_BASE_URL is unset in the environment — the `if not self.base_url` check at searxSearch.py:27 fires.
Common situations: Fresh checkout where .env was never created or not loaded (load_dotenv not called before construction); SEARXNG_BASE_URL defined in one shell but the app runs in another; typo'd env var name; self-hosted SearxNG not reachable so the URL was never configured.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Model not set
- Prompt file not found at path: {file_path}
- Permission denied to read prompt file at path: {file_path}
- Unknown provider: {provider_name}
- API key {api_key_var} not found in .env file. Please add it
AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30).
Data as JSON: /api/errors/ec09a6baa1de4854.
Report an issue: GitHub.