ConnectionRefusedError: [Errno 111] Connection refused error and workaround

If you’re running into the following error when running MAX Serve:

[2025-06-28 03:40:52] ERROR __init__.py:545: Exception while exporting metrics
Traceback (most recent call last):
  File "/home/ubuntu/quickstart  /.pixi/envs/default/lib/python3.12/site-packages/urllib3/connection.py", line 198, in _new_conn
    sock = connection.create_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/quickstart  /.pixi/envs/default/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/home/ubuntu/quickstart  /.pixi/envs/default/lib/python3.12/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

Run the following in your terminal to disable telemetry:
export OTEL_SDK_DISABLED=true

2 Likes

Some additional information: even with the workaround applied the endpoint may look like it’s not coming up. It’s likely the endpoint is alive and usable, but the availability isn’t logged. You can test this by running curl http://localhost:8000 from another console on the same system.