{"record":{"id":"137b61bfa91422b8","repo":"chroma-core/chroma","slug":"chroma-server-host-provided-in-settings-settings","errorCode":null,"errorMessage":"Chroma server host provided in settings[{settings.chroma_server_host}] is different to the one provided in HttpClient: [{host}]","messagePattern":"Chroma server host provided in settings\\[(.+?)\\] is different to the one provided in HttpClient: \\[(.+?)\\]","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/__init__.py","lineNumber":301,"sourceCode":"        ClientAPI: A configured client instance.\n\n    Raises:\n        ValueError: If settings specify a different host or port.\n    \"\"\"\n\n    if settings is None:\n        settings = Settings()\n\n    # Make sure parameters are the correct types -- users can pass anything.\n    host = str(host)\n    port = int(port)\n    ssl = bool(ssl)\n    tenant = str(tenant)\n    database = str(database)\n\n    settings.chroma_api_impl = \"chromadb.api.fastapi.FastAPI\"\n    if settings.chroma_server_host and settings.chroma_server_host != host:\n        raise ValueError(\n            f\"Chroma server host provided in settings[{settings.chroma_server_host}] is different to the one provided in HttpClient: [{host}]\"\n        )\n    settings.chroma_server_host = host\n    if settings.chroma_server_http_port and settings.chroma_server_http_port != port:\n        raise ValueError(\n            f\"Chroma server http port provided in settings[{settings.chroma_server_http_port}] is different to the one provided in HttpClient: [{port}]\"\n        )\n    settings.chroma_server_http_port = port\n    settings.chroma_server_ssl_enabled = ssl\n    settings.chroma_server_headers = headers\n\n    return ClientCreator(tenant=tenant, database=database, settings=settings)\n\n\nasync def AsyncHttpClient(\n    host: str = \"localhost\",\n    port: int = 8000,\n    ssl: bool = False,","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/__init__.py#L283-L319","documentation":"HttpClient() coerces its arguments (host = str(host) etc.) and then cross-checks them against Settings: if settings.chroma_server_host is already set and differs from the host argument, it raises ValueError (chromadb/__init__.py:299-303). The guard prevents a stale Settings value or environment variable from silently redirecting the client to a different server.","triggerScenarios":"HttpClient('10.0.0.5') while Settings(chroma_server_host='localhost') (or the corresponding env var) is still set; pointing the client at a new host without clearing the previously configured one.","commonSituations":".env files copied between local and staging; CI templates that set the server host globally; code that builds Settings once and reuses it with different host arguments.","solutions":["Make the values agree: pass the same host, or stop setting chroma_server_host in Settings when using HttpClient's host argument","Clear the stale configuration: unset the CHROMA_SERVER_HOST environment variable / remove the Settings keyword","Keep a single source of truth — configure the host in exactly one place (either Settings or the HttpClient argument)"],"exampleFix":"# before\nsettings = Settings(chroma_server_host='localhost')\nclient = HttpClient('10.0.0.5', settings=settings)  # ValueError\n\n# after\nclient = HttpClient('10.0.0.5')  # host set in one place only","handlingStrategy":"validation","validationCode":"def make_client(host: str, port: int, settings: Settings) -> chromadb.api.ClientAPI:\n    if settings.chroma_server_host and settings.chroma_server_host != host:\n        raise ValueError(\n            f'host conflict: settings={settings.chroma_server_host!r} vs argument={host!r}; '\n            'unset CHROMA_SERVER_HOST or align the values'\n        )\n    return chromadb.HttpClient(host=host, port=port, settings=settings)","typeGuard":null,"tryCatchPattern":"try:\n    client = chromadb.HttpClient(host, port, settings=settings)\nexcept ValueError as e:\n    if 'server host' in str(e):\n        # log the conflict, clear settings.chroma_server_host (or the env var), retry once\n        raise\n    raise","preventionTips":["Configure the host in exactly one place — either Settings/env or the HttpClient argument","Audit .env files when switching between local and remote servers","Assert settings.chroma_server_host is empty before constructing HttpClient from arguments"],"tags":["python","configuration","connection","settings","env-vars"],"backgroundTag":"connection-config-mismatch","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}