Unable to Connect to Milvus Database Using PyMilvus with Standalone Deployment via Docker Compose [closed]

I’m trying to run Milvus in standalone mode using Docker Compose, but I am unable to connect to the database using PyMilvus.

Here’s the setup I am using:

  • Milvus Version: [v2.5.0-beta]
  • PyMilvus Version: [2.3.1]

I first running as https://milvus.io/docs/install_standalone-docker-compose.md say:

wget https://github.com/milvus-io/milvus/releases/download/v2.5.0-beta/milvus-standalone-docker-compose.yml -O docker-compose.yml

sudo docker compose up -d

Then I create a simple python code like:

from pymilvus import connections

# Use host and port
connections.connect(
  alias="default", 
  host='localhost', 
  port='19530'
)

After running it, I got connection error:

(/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11) xiaowentao@host-04:/docker-home/xiaowentao/CAVDTUNER/milvus-standalone-test/source$ python test_connection.py 
Traceback (most recent call last):
  File "/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 131, in _wait_for_channel_ready
    grpc.channel_ready_future(self._channel).result(timeout=timeout)
  File "/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11/lib/python3.11/site-packages/grpc/_utilities.py", line 151, in result
    self._block(timeout)
  File "/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11/lib/python3.11/site-packages/grpc/_utilities.py", line 97, in _block
    raise grpc.FutureTimeoutError()
grpc.FutureTimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/docker-home/xiaowentao/CAVDTUNER/milvus-standalone-test/source/test_connection.py", line 4, in <module>
    connections.connect(
  File "/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11/lib/python3.11/site-packages/pymilvus/orm/connections.py", line 355, in connect
    connect_milvus(**kwargs, user=user, password=password, token=token, db_name=db_name)
  File "/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11/lib/python3.11/site-packages/pymilvus/orm/connections.py", line 302, in connect_milvus
    gh._wait_for_channel_ready(timeout=timeout)
  File "/home_backup/xiaowentao/miniconda/conda_base_env_pkg/conda-envs/base_env_3_11/lib/python3.11/site-packages/pymilvus/client/grpc_handler.py", line 134, in _wait_for_channel_ready
    raise MilvusException(
pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on localhost:19530. Timeout)>

I try this command line and verify that three docker containers are running normally:

docker ps | grep "milvus"
215ca6b1b9c1   milvusdb/milvus:v2.5.0-beta                      "/tini -- milvus run…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:9091->9091/tcp, :::9091->9091/tcp, 0.0.0.0:19530->19530/tcp, :::19530->19530/tcp   milvus-standalone
6d5fc50c9b77   minio/minio:RELEASE.2023-03-20T20-16-18Z         "/usr/bin/docker-ent…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:9000-9001->9000-9001/tcp, :::9000-9001->9000-9001/tcp                              milvus-minio
357e614e1687   quay.io/coreos/etcd:v3.5.5                       "etcd -advertise-cli…"   About a minute ago   Up About a minute (healthy)   2379-2380/tcp                                                                              milvus-etcd


nc -zv 127.0.0.1 19530
Connection to 127.0.0.1 19530 port [tcp/*] succeeded!

How can I connect to Milvus using PyMilvus successfully? Is there any additional configuration I need to set?

Any help or guidance would be greatly appreciated!

3

I try to figure it out by this way:

After setting up a proxy in the ~/.bashrc file with the following lines:

export http_proxy="http://xxx:port"  
export https_proxy="http://xxx:port"  

attempting to connect to Milvus via 127.0.0.1 or localhost results in one of the following two errors (based on tests across different machines):

Invalid connection parameters:

pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on localhost:19530, illegal connection params or server unavailable)>

Connection timeout:

pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on localhost:19530. Timeout)>

Root Cause:
The proxy settings interfere with the networking between Docker containers, causing the connection to fail.

Solution:
To resolve this issue, temporarily disable the proxy settings by clearing the environment variables:

export http_proxy=""  
export https_proxy=""  
source ~/.bashrc

Once the proxy is disabled, reconnecting to Milvus will work as expected.

If you encounter connection issues with Milvus while using proxies, ensure that the proxy settings do not affect local networking. This simple adjustment resolves the problem effectively.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật