Connection error with langchain

Hi, for days i’m tryng to use meu pinecone starter account but always show erros like when i Try to upload documentos in langchain. Last week work Just fine.

Http 403 “Project in subdomain didn’t match API keys project”

I already: create a New Key, create a New Index, check The env filé, The api, Project and env are alrigth. I try tô create a Index, my .evn dont have spaces or something like this.

Some time show erros tô Just check if The Index existe and other time to upload document with langchain

1 Like

Having the same issue here, did you manage to resolve it?

Same issue here. Did you resolve it?

The original error message doesn’t look like a Pinecone one, it could be coming from somewhere else. Could you share the full stacktrace to help narrow down where the problem is coming from?

I am facing same issue as well.
Exception has occurred: ForbiddenException
(403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({‘Content-Length’: ‘50’, ‘content-type’: ‘text/plain’, ‘date’: ‘Wed, 13 Dec 2023 07:58:02 GMT’, ‘server’: ‘envoy’, ‘Via’: ‘1.1 google’, ‘Alt-Svc’: ‘h3=“:443”; ma=2592000,h3-29=“:443”; ma=2592000’, ‘Connection’: ‘close’})
HTTP response body: Project in subdomain didn’t match API keys project
File “C:\D Drive\Platform\Pocs\langchain\pinecone_helper.py”, line 34, in pinecone_load
docsearch = Pinecone.from_texts([t.page_content for t in docs], embeddings, index_name=indexname)
File “C:\D Drive\Platform\Pocs\langchain\app.py”, line 36, in start
pc.pinecone_load(chunks,embedding,“langchain-chat-index1”)
File “C:\D Drive\Platform\Pocs\langchain\app.py”, line 40, in
lcd.start()
pinecone.core.client.exceptions.ForbiddenException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({‘Content-Length’: ‘50’, ‘content-type’: ‘text/plain’, ‘date’: ‘Wed, 13 Dec 2023 07:58:02 GMT’, ‘server’: ‘envoy’, ‘Via’: ‘1.1 google’, ‘Alt-Svc’: ‘h3=“:443”; ma=2592000,h3-29=“:443”; ma=2592000’, ‘Connection’: ‘close’})
HTTP response body: Project in subdomain didn’t match API keys project

Here is my code

config = OpenApiConfiguration.get_default_copy()
config.proxy = “http://XX:XXX:XXX:8080”
config.verify_ssl=False

    pinecone.init(api_key=self.pinecone_apikey,
          environment=self.pinecone_env,
          openapi_config= config,
          
          )
    #indexes =pinecone.list_indexes()
    if indexname not in pinecone.list_indexes():
           pinecone.create_index(name=indexname, metric="cosine", dimension=1536)
    docsearch = **Pinecone.from_texts**([t.page_content for t in docs], embeddings, index_name=indexname)

In this code you are creating an index named indexname but not checking if it is in the ready state before running a docsearch - resulting in the 400 error.

Run a do n while loop for some amount of time checking the indexes ready start and waiting and looping. Then once the index is ready you can docsearch!

if indexname not in pinecone.list_indexes():
      pinecone.create_index(name=indexname, metric="cosine", dimension=1536)
      #run a while loop here that checks and waits for index `indexname` to be in ready state

Hi Tim,

I checked the index was in ready state, but still facing the same issue

if index not in pinecone.list_indexes():
** pinecone.create_index(name=index, metric=“cosine”, dimension=1536)**

** print(pinecone.describe_index(index))**
** # docsearch = Pinecone.from_texts([t.page_content for t in docs], embeddings, index_name=indexname)**
** docsearch = Pinecone.from_documents(documents=docs,embedding=embeddings,index_name=index)**

IndexDescription(name=‘langchain-chat-index1’, metric=‘cosine’, replicas=1, dimension=1536.0, shards=1, pods=1, pod_type=‘starter’, status={‘ready’: True, ‘state’: ‘Ready’}, metadata_config=None, source_collection=‘’)

Embedding:
embeddings client=<class ‘openai.api_resources.embedding.Embedding’> async_client=None model=‘text-embedding-ada-002’ deployment=‘text-embedding-ada-002’ openai_api_version=‘’ openai_api_base=None openai_api_type=‘’ openai_proxy=‘’ embedding_ctx_length=8191 openai_api_key=‘sk-XXXXXXXXXX’ openai_organization=None allowed_special=set() disallowed_special=‘all’ chunk_size=1000 max_retries=2 request_timeout=None headers=None tiktoken_enabled=True tiktoken_model_name=None show_progress_bar=False model_kwargs={‘model_name’: ‘ada’}

Hi,

I am able to create index using the below code & I can see its status as active, however when I am upserting or even querying(after inserting the data from Pinecone UI), I am getting the same issue as above.

Application: Search Application

API Key: tried with both default and key1

Index: langchain-1

Create Index

config = OpenApiConfiguration.get_default_copy()

** config.proxy = “http://xxxx.com:8080”**

** config.verify_ssl=False**


** pinecone.init(api_key=self.pinecone_apikey,**

** environment=self.pinecone_env,**

** openapi_config= config,**

** )**


** if index_name not in pinecone.list_indexes():**

** pinecone.create_index(name=index_name, metric=“cosine”, dimension=384) #dimension=1536**


** print(pinecone.describe_index(index_name))**

** index = pinecone.Index(index_name)**

Upserting:

     index = pinecone.Index(index_name)

     sentences = ['This is an example sentence', 'This is another example sentence']

     model = SentenceTransformer('paraphrase-MiniLM-L6-v2')

     embeddings = model.encode(sentences).tolist()

     for i in range(len(sentences)):

          index.upsert(

              vectors=[(i, embeddings[i])],

              namespace="chaindemo"

          )

Querying

index = pinecone.Index(index_name)

    query_response = index.query(

        namespace="chaindemo",

        top_k=1,

        include_values=True,

        include_metadata=True,

        id="1000"

        # vector=[0.1, 0.2, 0.3, 0.4],

        # filter={

        #     "genre": {"$in": ["comedy", "documentary", "drama"]}

        # }

    )

Hi @77rishabh. Just to make sure I understand, you’re still seeing the same Http 403 “Project in subdomain didn’t match API keys project” error on upserts and queries?

What do you have as your self.pinecone_env variable? And what is the index name?

Also, fwiw, I checked your account, and I don’t see any indexes. So the create_index call is also failing, though I’m not sure why you’re not seeing any errors there.

All of this points to either the API key being incorrect, or the region/environment. Possibly a type in the environment setting, that’s more common than you might realize (we see a fair number of “gcp_starter” entries when the environment name is “gcp-starter”).