Remote milvus db not connecting #42474
Replies: 1 comment
-
you need to use URI in the connection args, now is working |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a milvus db that I started it on a remote VM using docker compose.
I can connect to it with Atto but when I try to connect using the library in python is not taking the host i set but is using the localhost
`from pymilvus import connections
from langchain_milvus import Milvus
host = "35.451.77.124"
port = "19530"
connections.connect(host=host, port=port)
print("Milvus connection established successfully!")
print("Active connections:", connections.list_connections())
class DummyEmbeddings:
def embed_documents(self, texts):
return [[0.1] * 768 for _ in texts]
def embed_query(self, text):
return [0.1] * 768
embeddings = DummyEmbeddings()
collection_name = "collection_name"
vectorstore = Milvus(
collection_name="...",
embedding_function=embeddings,
connection_args={
"host": "35.451.77.124",
"port": "19530",
"secure": False,
},
text_field="text",
vector_field="embedding",
auto_id=True,
)
print("Vectorstore created successfully!")
`
That is the code and bellow the exception
`python milvus_connect_test.py
/Users/a/Documents/git/ai/venv/lib/python3.12/site-packages/pymilvus/client/init.py:6: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import DistributionNotFound, get_distribution
Milvus connection established successfully!
Active connections: [('default', <pymilvus.client.grpc_handler.GrpcHandler object at 0x131a56d20>)]
2025-05-31 21:34:18,132 [ERROR][_create_connection]: Failed to create new connection using: 06717dac9e8149b2a72a0ace006cb90f (milvus_client.py:918)
Traceback (most recent call last):
File "/Users/a/Documents/git/ai/milvus_connect_test.py", line 24, in
vectorstore = Milvus(
^^^^^^^
File "/Users/a/Documents/git/ai/venv/lib/python3.12/site-packages/langchain_milvus/vectorstores/milvus.py", line 383, in init
self._milvus_client = MilvusClient(
^^^^^^^^^^^^^
File "/Users/a/Documents/git/ai/venv/lib/python3.12/site-packages/pymilvus/milvus_client/milvus_client.py", line 66, in init
self._using = self._create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/aa/Documents/git/ai/venv/lib/python3.12/site-packages/pymilvus/milvus_client/milvus_client.py", line 919, in _create_connection
raise ex from ex
File "/Users/ana/Documents/git/aig/venv/lib/python3.12/site-packages/pymilvus/milvus_client/milvus_client.py", line 916, in _create_connection
connections.connect(using, user, password, db_name, token, uri=uri, **kwargs)
File "/Users/a/Documents/git/ai/venv/lib/python3.12/site-packages/pymilvus/orm/connections.py", line 461, in connect
connect_milvus(**kwargs, user=user, password=password, token=token, db_name=db_name)
File "/Users/a/Documents/git/ai/venv/lib/python3.12/site-packages/pymilvus/orm/connections.py", line 411, in connect_milvus
gh._wait_for_channel_ready(timeout=timeout)
File "/Users/a/Documents/git/ai/venv/lib/python3.12/site-packages/pymilvus/client/grpc_handler.py", line 152, in _wait_for_channel_ready
raise MilvusException(
pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on localhost:19530, illegal connection params or server unavailable)>
`
What I'm doing it wrong?
Beta Was this translation helpful? Give feedback.
All reactions