Illustration Image

error 111- Connection refused for cassandra

I am learning to use Datastax AstraDB to vector storage. I am trying to follow a tutorial. I am using cassio to connect with astraDB using the following code:

ASTRA_DB_APPLICATION_TOKEN = os.environ.get("ASTRA_DB_APPLICATION_TOKEN")
ASTRA_DB_ID = os.environ.get("ASTRA_DB_ID")
cassio.init(token=ASTRA_DB_APPLICATION_TOKEN,database_id=ASTRA_DB_ID)

There seems to be no warning or error for the above code. But when I try to store the vectors, I get the error

from langchain.vectorstores.cassandra import Cassandra
embeddings = OllamaEmbeddings(model="llama3")
session = None
astra_vector_store = Cassandra(
    embedding=embeddings,
    table_name="groq_project",
    session=session
)

Here is the full error:

---------------------------------------------------------------------------
ConnectError                              Traceback (most recent call last)
File /home/time/miniconda3/envs/bias-vision/lib/python3.9/site-packages/httpx/_transports/default.py:72, in map_httpcore_exceptions()
     71 try:
---> 72     yield
     73 except Exception as exc:

File /home/time/miniconda3/envs/bias-vision/lib/python3.9/site-packages/httpx/_transports/default.py:236, in HTTPTransport.handle_request(self, request)
    235 with map_httpcore_exceptions():
--> 236     resp = self._pool.handle_request(req)
    238 assert isinstance(resp.stream, typing.Iterable)

File /home/time/miniconda3/envs/bias-vision/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py:256, in ConnectionPool.handle_request(self, request)
    255     self._close_connections(closing)
--> 256     raise exc from None
    258 # Return the response. Note that in this case we still have to manage
    259 # the point at which the response is closed.

File /home/time/miniconda3/envs/bias-vision/lib/python3.9/site-packages/httpcore/_sync/connection_pool.py:236, in ConnectionPool.handle_request(self, request)
    234 try:
    235     # Send the request on the assigned connection.
--> 236     response = connection.handle_request(
    237         pool_request.request
    238     )
    239 except ConnectionNotAvailable:
...
     86     raise
     88 message = str(exc)
---> 89 raise mapped_exc(message) from exc

ConnectError: [Errno 111] Connection refused
Become part of our
growing community!
Welcome to Planet Cassandra, a community for Apache Cassandra®! We're a passionate and dedicated group of users, developers, and enthusiasts who are working together to make Cassandra the best it can be. Whether you're just getting started with Cassandra or you're an experienced user, there's a place for you in our community.
A dinosaur
Planet Cassandra is a service for the Apache Cassandra® user community to share with each other. From tutorials and guides, to discussions and updates, we're here to help you get the most out of Cassandra. Connect with us and become part of our growing community today.
© 2009-2023 The Apache Software Foundation under the terms of the Apache License 2.0. Apache, the Apache feather logo, Apache Cassandra, Cassandra, and the Cassandra logo, are either registered trademarks or trademarks of The Apache Software Foundation. Sponsored by Anant Corporation and Datastax, and Developed by Anant Corporation.

Get Involved with Planet Cassandra!

We believe that the power of the Planet Cassandra community lies in the contributions of its members. Do you have content, articles, videos, or use cases you want to share with the world?