{"record":{"id":"3e01298121dcb120","repo":"reflex-dev/reflex","slug":"bad-hostname-provided","errorCode":null,"errorMessage":"bad hostname provided","messagePattern":"bad hostname provided","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py","lineNumber":1491,"sourceCode":"\n    Returns:\n        dict: The hostname details as a dictionary.\n\n    Raises:\n        NotAuthenticatedError: If the token is not valid.\n        Exception: If deployment fails or the hostname is invalid.\n\n    \"\"\"\n    import httpx\n\n    if not isinstance(client, AuthenticatedClient):\n        raise NotAuthenticatedError(\"not authenticated\")\n\n    data = {\"app_id\": app_id, \"app_name\": app_name}\n    if hostname:\n        clean_hostname = extract_subdomain(hostname)\n        if clean_hostname is None:\n            raise Exception(\"bad hostname provided\")\n        data[\"hostname\"] = clean_hostname\n    response = httpx.post(\n        urljoin(constants.Hosting.HOSTING_SERVICE, \"/api/v1/apps/reserve\"),\n        headers=authorization_header(client.token),\n        json=data,\n        timeout=constants.Hosting.TIMEOUT,\n    )\n    try:\n        response.raise_for_status()\n    except httpx.HTTPStatusError as ex:\n        if ex.response.status_code == 413:\n            raise Exception(\n                \"deployment failed: the deployment payload is too large (over 100MB). \"\n                \"Please reduce the size of your project by removing large files or \"\n                \"adding them to your .gitignore file.\"\n            ) from ex\n        try:\n            ex_details = ex.response.json().get(\"detail\")","sourceCodeStart":1473,"sourceCodeEnd":1509,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py#L1473-L1509","documentation":"Raised by get_hostname when an explicit hostname argument cannot be reduced to a valid subdomain: extract_subdomain returns None, meaning the string has no usable subdomain part. This is a client-side validation failure before the reserve request is sent.","triggerScenarios":"Passing a bare domain without a subdomain, an empty string, or a malformed value as the hostname argument to `reflex deploy --hostname` / get_hostname.","commonSituations":"Users passing a full custom domain they own, a domain with only dots/TLD, or a typo'd hostname; hosting a custom apex domain instead of a subdomain.","solutions":["Pass a plain subdomain (e.g. `my-app`) or a URL whose subdomain is extractable, like `my-app.reflex.run`","Check that the hostname is non-empty and contains at least one label before a dot","Avoid protocol prefixes and paths in the hostname value"],"exampleFix":"# before\nget_hostname(client, app_id, app_name, hostname=\"example.com\")\n\n# after\nget_hostname(client, app_id, app_name, hostname=\"my-app.reflex.run\")","handlingStrategy":"validation","validationCode":"from reflex_cli.utils.hosting import extract_subdomain\nassert hostname and extract_subdomain(hostname) is not None, \"hostname must contain a valid subdomain\"","typeGuard":"def is_valid_hostname(hostname: str) -> bool:\n    return bool(hostname) and extract_subdomain(hostname) is not None","tryCatchPattern":"try:\n    get_hostname(client, app_id, app_name, hostname=hostname)\nexcept Exception as e:\n    if \"bad hostname\" in str(e):\n        hostname = None  # fall back to default\n        get_hostname(client, app_id, app_name)","preventionTips":["Pass a plain subdomain like 'my-app' rather than a full domain","Test custom hostnames with extract_subdomain before deploying","Avoid apex domains and URLs with schemes/paths"],"tags":["reflex","hosting","hostname","validation","deploy"],"backgroundTag":"invalid-hostname-format","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}