{"record":{"id":"3fc2146dd8d6d430","repo":"locustio/locust","slug":"you-must-specify-the-base-host-either-in-the-host","errorCode":null,"errorMessage":"You must specify the base host. Either in the host attribute in the User class, or on the command line using the --host option.","messagePattern":"You must specify the base host\\. Either in the host attribute in the User class, or on the command line using the --host option\\.","errorType":"exception","errorClass":"StopTest","httpStatus":null,"severity":"critical","filePath":"locust/contrib/fasthttp.py","lineNumber":421,"sourceCode":"\n        from geventhttpclient.client import HTTPClientPool\n\n        class MyUser(FastHttpUser):\n            client_pool = HTTPClientPool(concurrency=5)\n    \"\"\"\n\n    ssl_context_factory: Callable | None = None\n    \"\"\"A callable that return a SSLContext for overriding the default context created by the FastHttpSession.\"\"\"\n\n    abstract = True\n    \"\"\"Dont register this as a User class that can be run by itself\"\"\"\n\n    _callstack_regex = re.compile(r'  File \"(\\/.[^\"]*)\", line (\\d*),(.*)')\n\n    def __init__(self, environment) -> None:\n        super().__init__(environment)\n        if self.host is None:\n            raise StopTest(\n                \"You must specify the base host. Either in the host attribute in the User class, or on the command line using the --host option.\"\n            )\n\n        self.client: FastHttpSession = FastHttpSession(\n            base_url=self.host,\n            request_event=self.environment.events.request,\n            network_timeout=self.network_timeout,\n            connection_timeout=self.connection_timeout,\n            max_redirects=self.max_redirects,\n            max_retries=self.max_retries,\n            insecure=self.insecure,\n            concurrency=self.concurrency,\n            user=self,\n            client_pool=self.client_pool,\n            ssl_context_factory=self.ssl_context_factory,\n            headers=self.default_headers,\n            proxy_host=self.proxy_host,\n            proxy_port=self.proxy_port,","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/contrib/fasthttp.py#L403-L439","documentation":"FastHttpUser.__init__ validates that a base host is available. If self.host is None (no host attribute on the User class and no --host option), it raises StopTest, aborting the test start. FastHttpSession requires a base_url to build request URLs.","triggerScenarios":"Defining a FastHttpUser subclass without a `host` class attribute and running locust without `--host`; host accidentally set to None (e.g. from an unset env variable).","commonSituations":"Shared locustfiles relying on --host that wasn't passed on the command line; env-var-driven host configuration where the variable is missing; headless runs omitting --host.","solutions":["Add `host = \"https://example.com\"` to your FastHttpUser class","Pass `--host https://example.com` on the locust command line","If host comes from an env var, validate/set it before `locust.start()` and fail fast with a clear message","Provide host via locust.conf (`host = ...`)"],"exampleFix":"// before\nclass MyUser(FastHttpUser):\n    tasks = [MyTasks]  # no host\n// after\nclass MyUser(FastHttpUser):\n    host = \"https://example.com\"\n    tasks = [MyTasks]","handlingStrategy":"validation","validationCode":"import os\nhost = os.getenv(\"TARGET_HOST\")\nassert host, \"TARGET_HOST env var or --host is required\"","typeGuard":"def has_host(user):\n    return isinstance(getattr(user, \"host\", None), str) and user.host.startswith((\"http://\", \"https://\"))","tryCatchPattern":"try:\n    MyUser(env)  # or locust run\nexcept StopTest as e:\n    logger.error(\"configure host: %s\", e)","preventionTips":["Set a default host attribute in every FastHttpUser","Always pass --host in headless/CI invocations","Use locust.conf with host defined"],"tags":["locust","fasthttp","configuration","missing-host"],"backgroundTag":"missing-required-config","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}