I had followed the steps given in https://docs.datastax.com/en/developer/python-driver/3.25/getting_started/ to connect to cassandra database using python code, but still after running the code snippet I am getting
NoHostAvailable: ('Unable to connect to any servers', {'hosts"port': OperationTimedOut('errors=None, last_host=None'),
- Python version 2.7 and 3 (classpath is set for both the python versions)
- Java 1.8 (class path has been set)
- Apache cassandra 3.11.6 (apache home classpath has been set)
So that error message suggests that the host/port combination either does not have Cassandra running on it or is under heavy load and unable to respond.
Can you edit your question to include the Cassandra connection portion of your code, as well as maybe how you're calling it? I have a test script which I use (and you're welcome to check it out), and here is the connection portion:
I call it like this:
One thing you might try too, would be to run a
nodetool statuson the cluster just to make sure it's running ok.Edit
So this sounds to me like you're attempting a
session.executebeforesession = cluster.connect(). Have a look at my Git repo (linked above) to see the correct order for instantiatingsession.In that case, make sure the
portis being set in the cluster definition. Ex: