pinecone.core.exceptions.PineconeProtocolError: Failed to connect; did you specify the correct index name?

Hi,

I ran a code last week which was running fine but when I ran the same code this week it started throwing the error:

Connected to pydev debugger (build 231.9011.38)
Traceback (most recent call last):
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 491, in _make_request
raise new_e
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 467, in _make_request
self._validate_conn(conn)
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 1092, in _validate_conn
conn.connect()
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connection.py”, line 635, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connection.py”, line 776, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\util\ssl
.py", line 466, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\util\ssl
.py", line 510, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\program files\python311\Lib\ssl.py”, line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\program files\python311\Lib\ssl.py”, line 1075, in _create
self.do_handshake()
File “c:\program files\python311\Lib\ssl.py”, line 1346, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\utils\error_handling.py”, line 17, in inner_func
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\index.py”, line 455, in query
response = self._vector_api.query(
^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\api_client.py”, line 776, in call
return self.callable(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\api\vector_operations_api.py”, line 716, in __query
return self.call_with_http_info(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\api_client.py”, line 838, in call_with_http_info
return self.api_client.call_api(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\api_client.py”, line 413, in call_api
return self.__call_api(resource_path, method,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\api_client.py”, line 200, in __call_api
response_data = self.request(
^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\api_client.py”, line 459, in request
return self.rest_client.POST(url,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\rest.py”, line 271, in POST
return self.request(“POST”, url,
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\client\rest.py”, line 157, in request
r = self.pool_manager.request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3_request_methods.py”, line 118, in request
return self.request_encode_body(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3_request_methods.py”, line 217, in request_encode_body
return self.urlopen(method, url, **extra_kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\poolmanager.py”, line 443, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 844, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\util\retry.py”, line 470, in increment
raise reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\util\util.py”, line 38, in reraise
raise value.with_traceback(tb)
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 491, in _make_request
raise new_e
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 467, in _make_request
self._validate_conn(conn)
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connectionpool.py”, line 1092, in _validate_conn
conn.connect()
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connection.py”, line 635, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\connection.py”, line 776, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\util\ssl
.py", line 466, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\urllib3\util\ssl
.py", line 510, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\program files\python311\Lib\ssl.py”, line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “c:\program files\python311\Lib\ssl.py”, line 1075, in _create
self.do_handshake()
File “c:\program files\python311\Lib\ssl.py”, line 1346, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, ConnectionResetError(10054, ‘An existing connection was forcibly closed by the remote host’, None, 10054, None))

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

Traceback (most recent call last):
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\chains\base.py”, line 149, in call
raise e
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\chains\base.py”, line 143, in call
self._call(inputs, run_manager=run_manager)
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\chains\conversational_retrieval\base.py”, line 110, in _call
docs = self._get_docs(new_question, inputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\chains\conversational_retrieval\base.py”, line 191, in _get_docs
docs = self.retriever.get_relevant_documents(question)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\vectorstores\base.py”, line 392, in get_relevant_documents
docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\vectorstores\pinecone.py”, line 158, in similarity_search
docs_and_scores = self.similarity_search_with_score(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\langchain\vectorstores\pinecone.py”, line 120, in similarity_search_with_score
results = self._index.query(
^^^^^^^^^^^^^^^^^^
File “C:\Users\kalpa.virtualenvs\documentation-helper-iXNYOILM\Lib\site-packages\pinecone\core\utils\error_handling.py”, line 25, in inner_func
raise PineconeProtocolError(f’Failed to connect; did you specify the correct index name?') from e
pinecone.core.exceptions.PineconeProtocolError: Failed to connect; did you specify the correct index name?
python-BaseException

Hi @rajaniesh

Check to see if the index has been deleted.

Running index.query, etc. with a non-existent index name will return the message "Failed to connect; did you specify the correct index name?

if index_name not in pinecone.list_indexes():
# we create a new index
pinecone.create_index(
name=index_name,
metric=‘cosine’,
dimension=1536
)

I am running the same query, and trying to delete a specific namespace in an index.

Thing is, even if the namespace exists it throws this error when I run the script through a DAG on airflow.

When I run the exact same code on a jupyter notebook, everything works fine.

Even if I enter a non-existent namespace for the same index, code still runs, does not give an error.

Any clue as to what is the case here?