{"record":{"id":"420238e190f51a23","repo":"mlflow/mlflow","slug":"wait-scoring-server-ready-timeout","errorCode":null,"errorMessage":"Wait scoring server ready timeout.","messagePattern":"Wait scoring server ready timeout\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mlflow/pyfunc/scoring_server/client.py","lineNumber":74,"sourceCode":"        return resp_status.text\n\n    def wait_server_ready(self, timeout=30, scoring_server_proc=None):\n        begin_time = time.time()\n\n        while True:\n            time.sleep(0.3)\n            try:\n                self.ping()\n                return\n            except Exception:\n                pass\n            if time.time() - begin_time > timeout:\n                break\n            if scoring_server_proc is not None:\n                return_code = scoring_server_proc.poll()\n                if return_code is not None:\n                    raise RuntimeError(f\"Server process already exit with returncode {return_code}\")\n        raise RuntimeError(\"Wait scoring server ready timeout.\")\n\n    def invoke(self, data, params: dict[str, Any] | None = None):\n        \"\"\"\n        Args:\n            data: Model input data.\n            params: Additional parameters to pass to the model for inference.\n\n        Returns:\n            :py:class:`PredictionsResponse <mlflow.deployments.PredictionsResponse>` result.\n        \"\"\"\n        response = requests.post(\n            url=self.url_prefix + \"/invocations\",\n            data=dump_input_data(data, params=params),\n            headers={\"Content-Type\": scoring_server.CONTENT_TYPE_JSON},\n        )\n        if response.status_code != 200:\n            raise Exception(\n                f\"Invocation failed (error code {response.status_code}, response: {response.text})\"","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/pyfunc/scoring_server/client.py#L56-L92","documentation":"wait_server_ready() loops until either the server responds or `timeout` seconds elapse; after breaking out of the loop it unconditionally raises RuntimeError('Wait scoring server ready timeout.'). It means the server never answered the health probe within the allotted time while the process itself was still alive.","triggerScenarios":"Calling wait_server_ready() when the scoring server takes longer than `timeout` (default 30s) to start listening — slow model load, cold start, heavy dependency import — or when the client is polling the wrong host/port.","commonSituations":"Large models or slow disk making startup exceed 30s; wrong port/host in url_prefix so pings never succeed; server bound to localhost but client using container hostname.","solutions":["Increase the timeout argument (e.g. wait_server_ready(timeout=300)) for slow-loading models","Verify url_prefix host/port match the server's --host/--port","Pass scoring_server_proc so early crashes fail fast with returncode instead of timing out","Check server logs to confirm it is actually listening; add retries around startup"],"exampleFix":"// before\nclient.wait_server_ready()  # default 30s\n// after\nclient.wait_server_ready(timeout=300, scoring_server_proc=proc)","handlingStrategy":"retry","validationCode":"import socket\n\ndef port_open(host: str, port: int) -> bool:\n    with socket.socket() as s:\n        s.settimeout(2)\n        return s.connect_ex((host, port)) == 0","typeGuard":null,"tryCatchPattern":"try:\n    client.wait_server_ready(timeout=300, scoring_server_proc=proc)\nexcept RuntimeError as e:\n    if \"timeout\" in str(e):\n        print(\"server alive but not ready in 300s; check logs\", proc.stdout.read())\n    raise","preventionTips":["Set timeout proportional to model load time","Pass scoring_server_proc so early crashes fail fast","Confirm host/port match the server bind address","Monitor server logs during startup"],"tags":["timeout","scoring-server","startup"],"backgroundTag":"server-ready-timeout","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}