MlflowException
mlflow.exceptions.MlflowException
Stack trace
mlflow.exceptions.MlflowException: Model registry not found: 'my_model'
File "/usr/local/lib/python3.9/site-packages/mlflow/tracking/client.py", line 123, in get_registered_model
raise MlflowException(f"Model registry not found: '{name}'") Why it happens
This error occurs when MLflow's client attempts to access a registered model that does not exist in the configured tracking server or the model registry is not properly set up. It can also happen if the tracking URI is misconfigured or the user lacks permissions.
Detection
Catch MlflowException when calling get_registered_model or related registry APIs and log the model name and tracking URI to detect missing or misconfigured registries before crashing.
Causes & fixes
The specified registered model name does not exist in the MLflow tracking server.
Verify the model name spelling and ensure the model is registered in the MLflow tracking server before accessing it.
MLflow tracking URI is not set or points to the wrong server without the model registry.
Set the correct MLflow tracking URI using mlflow.set_tracking_uri() or environment variable MLFLOW_TRACKING_URI to point to the server hosting the model registry.
Insufficient permissions to access the model registry on the MLflow server.
Ensure your MLflow client has proper authentication and authorization to access the model registry, such as setting up credentials or tokens.
Code: broken vs fixed
import mlflow
client = mlflow.tracking.MlflowClient()
# This line raises MlflowException if model not found
model = client.get_registered_model("my_model") import os
import mlflow
os.environ["MLFLOW_TRACKING_URI"] = "https://my-mlflow-server.com"
client = mlflow.tracking.MlflowClient()
# Fixed: ensure model exists and tracking URI is set
model = client.get_registered_model("my_model")
print(f"Model info: {model}") Workaround
Wrap get_registered_model call in try/except MlflowException, and if caught, fallback to creating the model or logging a warning to handle missing registry gracefully.
Prevention
Always configure and verify MLflow tracking URI and model registry existence during deployment and CI/CD pipelines to prevent runtime registry access errors.