{"record":{"id":"c17fd81666d707da","repo":"MemPalace/mempalace","slug":"qdrant-request-failed-exc-reason","errorCode":null,"errorMessage":"Qdrant request failed: {exc.reason}","messagePattern":"Qdrant request failed: (.+?)","errorType":"exception","errorClass":"BackendError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/qdrant.py","lineNumber":400,"sourceCode":"        url = f\"{self._config.url}{path}\"\n        if query:\n            url = f\"{url}?{urlparse.urlencode(query)}\"\n        data = None\n        headers = {\"Content-Type\": \"application/json\"}\n        if self._config.api_key:\n            headers[\"api-key\"] = self._config.api_key\n        if body is not None:\n            data = json.dumps(body, ensure_ascii=False).encode(\"utf-8\")\n        req = urlrequest.Request(url, data=data, method=method, headers=headers)\n        try:\n            with urlrequest.urlopen(req, timeout=self._config.timeout) as resp:\n                raw = resp.read()\n        except urlerror.HTTPError as exc:\n            raw = exc.read()\n            detail = raw.decode(\"utf-8\", errors=\"replace\") if raw else str(exc)\n            raise _QdrantHTTPError(exc.code, detail) from exc\n        except urlerror.URLError as exc:\n            raise BackendError(f\"Qdrant request failed: {exc.reason}\") from exc\n        if not raw:\n            return {}\n        try:\n            return json.loads(raw.decode(\"utf-8\"))\n        except json.JSONDecodeError as exc:\n            raise BackendError(\"Qdrant returned invalid JSON\") from exc\n\n    def collection_exists(self, collection: str) -> bool:\n        try:\n            self.request(\"GET\", f\"/collections/{urlparse.quote(collection, safe='')}\")\n        except _QdrantHTTPError as exc:\n            if exc.status == 404:\n                return False\n            raise\n        return True\n\n    def get_collection_info(self, collection: str) -> dict:\n        return self.request(\"GET\", f\"/collections/{urlparse.quote(collection, safe='')}\")","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/qdrant.py#L382-L418","documentation":"Raised by QdrantClient.request() when the underlying urllib request fails at the transport level (urlerror.URLError) — i.e. the HTTP request to the Qdrant server never completed. The exception reason (connection refused, DNS failure, timeout, TLS error) is wrapped in BackendError.","triggerScenarios":"Qdrant server not running or wrong URL/port in backend config, DNS resolution failure for a remote host, TCP connection refused, TLS certificate error on https endpoints, or a network drop mid-request.","commonSituations":"Qdrant docker container stopped or not started; misconfigured host/port (default gRPC port 6334 used instead of REST 6333); firewall blocking egress; kubernetes pod not ready; TLS self-signed cert rejected by urllib.","solutions":["Verify Qdrant is reachable: curl http://<host>:<port>/collections from the same machine","Fix the URL/port in the backend config (REST API is typically 6333, not the gRPC port 6334)","Start the server: docker run -p 6333:6333 qdrant/qdrant or restart the service","For TLS issues, install a trusted cert or point at the http endpoint; for transient drops, retry the operation (upsert is idempotent by id)","Wrap collection calls in try/except BackendError and surface a clear 'Qdrant unavailable' message"],"exampleFix":"# before\n backend_config = QdrantConfig(url=\"http://localhost:6334\")  # wrong: gRPC port\n# after\n backend_config = QdrantConfig(url=\"http://localhost:6333\")  # REST API port","handlingStrategy":"retry","validationCode":"import socket, urlrequest\n\ndef qdrant_up(url, port, timeout=2):\n    try:\n        urlrequest.urlopen(f\"http://{url}:{port}/\", timeout=timeout)\n        return True\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"from mempalace.backends.base import BackendError\ntry:\n    collection.get(ids=[\"x\"])\nexcept BackendError as e:\n    if \"Qdrant request failed\" in str(e):\n        # connection-level failure: check server, then retry after fixing\n        ...","preventionTips":["Health-check the Qdrant URL at app startup before any writes","Use the REST port (6333 by default), not gRPC 6334","Run Qdrant with a persistent volume and a supervised restart policy","Make upserts idempotent (stable ids) so retries after network errors are safe"],"tags":["network","qdrant","connection","configuration"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}