Skip to main content

Fixed: An MLflow Model Container Answers 404 for /health and /version

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A model container built with mlflow models build-docker answered /ping and /invocations, but /health and /version answered HTTP/1.1 404 Not Found with a body of {}. MLflow's guide lists /health as the same as /ping, and both work with mlflow models serve. In the image, nginx sits in front of the model server and forwards only /ping and /invocations. The fix is to health-check the container with /ping.

What I Was Doing​

In Part 9 of the MLflow series, I served the shopper project's champion model with mlflow models serve first, where all four endpoints from MLflow's guide answered, and then in a Docker image built with mlflow models build-docker (MLflow 3.18.0). The guide to deploying a model locally lists them:

  • /invocations: An inference endpoint that accepts POST requests with input data and returns predictions.
  • /ping: Used for health checks.
  • /health: Same as /ping
  • /version: Returns the MLflow version.

I started the container with its port 8080 published on my computer's port 5001:

Terminal
docker run -d --name shopper-api --platform linux/amd64 -e MLFLOW_MODELS_WORKERS=2 -p 127.0.0.1:5001:8080 shopper-purchase-prediction:2

Then I asked it for /health, to use it as the container's health check.

What I Expected​

200 OK, as from mlflow models serve.

What I Got​

Terminal
curl -i http://127.0.0.1:5001/health
Output
HTTP/1.1 404 Not Found
Server: nginx/1.26.3
Date: Thu, 26 Nov 2026 05:21:27 GMT
Content-Type: application/octet-stream
Content-Length: 2
Connection: keep-alive

{}

curl's output in a terminal: HTTP/1.1 404 Not Found from Server nginx/1.26.3, with a two-byte body of {}.

/version gave the same 404 and {}.

What I Checked​

Who answered. Server: nginx/1.26.3. With mlflow models serve the answers say server: uvicorn, the model server itself, so in the container something else is in front of it.

What that nginx forwards. The image runs nginx with a configuration file from MLflow. I printed its location blocks from inside the running container:

Terminal
docker exec shopper-api grep -n -A1 'location' /usr/local/lib/python3.15/site-packages/mlflow/models/container/scoring_server/nginx.conf
Output
27: location ~ ^/(ping|invocations) {
28- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
--
35: location / {
36- return 404 "{}";

Only paths that start with /ping or /invocations go on to the model server. Everything else, /health and /version included, gets nginx's own 404 with {}.

Why It Happens​

mlflow models serve runs the model server, uvicorn, directly, so every endpoint it has answers. An image from mlflow models build-docker starts nginx on port 8080 in front of uvicorn, and MLflow's nginx.conf passes on only /ping and /invocations. The guide describes the model server's endpoints, not what the container lets through.

The Fix​

Health-check the container with /ping, which nginx forwards:

Terminal
curl -i http://127.0.0.1:5001/ping

After the Fix​

Output
HTTP/1.1 200 OK
Server: nginx/1.26.3
Date: Thu, 26 Nov 2026 05:21:29 GMT
Content-Type: application/json
Content-Length: 1
Connection: keep-alive

curl's output in a terminal: HTTP/1.1 200 OK from Server nginx/1.26.3 for /ping, with Content-Type application/json.

200 OK from the same container: nginx passed /ping to the model server, which answered that the model is loaded.

Common Mistakes​

MistakeWhat happensDo this instead
A container health check on /healthAlways 404, so the container looks unhealthyCheck /ping
Reading the MLflow version from /version in the container404 and {}Use /version with mlflow models serve; the image's Dockerfile installs mlflow==3.18.0
Turning nginx off to reach /healthWith DISABLE_NGINX=true alone, nothing answers from outsideFixed: curl: (52) Empty reply from server with DISABLE_NGINX

Troubleshooting​

SymptomLikely causeFix
/ping answers 502 Bad Gateway right after docker runnginx is up but the model server is still startingWait a few seconds and try again
curl: (52) Empty reply from server right after docker runThe container is starting and nginx isn't listening yetWait a few seconds and try again

FAQ​

Why does the image use nginx at all?​

MLflow's container starts nginx and uvicorn together, as the build-docker reference notes: "by default, the container will start nginx and uvicorn processes". nginx is what listens on port 8080.

Does /ping check the model?​

The model server answers /ping with 200 once it has loaded the model, which is what a health check needs.

Conclusion​

In an MLflow model image, nginx listens on port 8080 and forwards only /ping and /invocations to the model server, so /health and /version, which work with mlflow models serve, answer 404 {}. Health-checking the container with /ping gave 200 OK.

Additional Resources​