{"record":{"id":"09a1765b0bf0b46b","repo":"crewAIInc/crewAI","slug":"failed-to-connect-to-enterprise-url-e-s","errorCode":null,"errorMessage":"Failed to connect to enterprise URL: {e!s}","messagePattern":"Failed to connect to enterprise URL: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/enterprise/main.py","lineNumber":66,"sourceCode":"                \"X-Crewai-Version\": get_crewai_version(),\n            }\n            response = httpx.get(oauth_endpoint, timeout=30, headers=headers)\n            response.raise_for_status()\n\n            try:\n                oauth_config = response.json()\n            except json.JSONDecodeError as e:\n                raise ValueError(f\"Invalid JSON response from {oauth_endpoint}\") from e\n\n            self._validate_oauth_config(oauth_config)\n\n            console.print(\n                \"✅ Successfully retrieved OAuth2 configuration\", style=\"green\"\n            )\n            return cast(dict[str, Any], oauth_config)\n\n        except httpx.HTTPError as e:\n            raise ValueError(f\"Failed to connect to enterprise URL: {e!s}\") from e\n        except Exception as e:\n            raise ValueError(f\"Error fetching OAuth2 configuration: {e!s}\") from e\n\n    def _update_oauth_settings(\n        self, enterprise_url: str, oauth_config: dict[str, Any]\n    ) -> None:\n        try:\n            config_mapping = {\n                \"enterprise_base_url\": enterprise_url,\n                \"oauth2_provider\": oauth_config[\"provider\"],\n                \"oauth2_audience\": oauth_config[\"audience\"],\n                \"oauth2_client_id\": oauth_config[\"device_authorization_client_id\"],\n                \"oauth2_domain\": oauth_config[\"domain\"],\n                \"oauth2_extra\": oauth_config[\"extra\"],\n            }\n\n            console.print(\"🔄 Updating local OAuth2 configuration...\")\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/enterprise/main.py#L48-L84","documentation":"Raised when the HTTP request to the enterprise OAuth2 discovery endpoint fails at the transport level — httpx.HTTPError covers connect errors, DNS failures, timeouts (30s limit in the code), and raise_for_status() 4xx/5xx responses. The CLI wraps it into ValueError('Failed to connect to enterprise URL: ...') so the original exception text (e.g. '[Errno -2] Name or service not known' or '401 Unauthorized') is embedded in the message.","triggerScenarios":"`crewai enterprise connect <url>` where the host is unresolvable, the server refuses the connection, a TLS certificate fails verification, the request exceeds the 30-second timeout, or the endpoint returns any non-2xx status (raise_for_status).","commonSituations":"Typos in the enterprise URL, VPN/internal-host not reachable from the current machine, self-signed certificates without CA trust, firewalls dropping egress, or the enterprise service being down during onboarding.","solutions":["Verify reachability: curl -v <enterprise_url> from the same machine and network","Fix DNS/VPN: connect to the VPN or correct the hostname before retrying","For self-signed TLS, add the CA to the system trust store (httpx uses certifi/system CAs)","If a 4xx/5xx came back, inspect the status code in the message and fix server-side auth/routing"],"exampleFix":"# before\ncrewai enterprise connect https://crewai.acme.co\r\n# ValueError: Failed to connect to enterprise URL: [Errno -2] Name or service not known\r\n# after (resolve DNS / connect VPN first, verify, then retry)\ncurl -v https://crewai.acme.co/.well-known/oauth-config\r\ncrewai enterprise connect https://crewai.acme.co","handlingStrategy":"retry","validationCode":"import httpx\n\ndef enterprise_reachable(url: str) -> bool:\n    try:\n        return httpx.get(url, timeout=30).status_code < 500\n    except httpx.HTTPError:\n        return False","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        enterprise_cmd.connect(url)\n        break\n    except ValueError as e:\n        if \"Failed to connect\" not in str(e) or attempt == 2:\n            raise\n        time.sleep(2 ** attempt)","preventionTips":["curl -v the enterprise URL before onboarding","Confirm DNS/VPN/TLS trust from the machine running the CLI","Treat connect failures as transient first (timeout), config second (DNS/TLS)"],"tags":["network","enterprise","oauth","connectivity"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}