# Weaviate server closes connection unexpectedly

**URL:** <https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626>\
**Category:** Support\
**Created:** [September 6, 2023, 8:24am UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626 "2023-09-06T08:24:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![alt-glitch](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/alt-glitch/32/378_2.png) [@alt-glitch](https://forum.weaviate.io/u/alt-glitch)\
**Post date:** [September 6, 2023, 8:24am UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/1 "2023-09-06T08:24:46Z")

</div>

Hi there!  
On importing data to weaviate, I check if the class exists.  
**But quite often it fails to check if a class exists**.

```auto
requests.exceptions.ConnectionError: Checking class existence could not be done.

```

I think it’s because the server closes the connection unexpectedly.  
This is how I check for the class existence.

```python
# PYTHON CODE TO SAVE OBJECT 
source_class = settings.KNOWLEDGE_SOURCE_CLASS.format(user_id)
content_class = settings.CONTENT_CLASS.format(user_id)
    try:
        if not client.schema.exists(source_class):
            print("[!] Schema doesn't exist. Initializing...")
            logger.debug(f"Initializing {user_id} schema")
            knowledge_source = {...}
            content = {...}
            client.schema.create({"classes": [knowledge_source, content]})

```

I end up getting the following error:

```auto
  File "/home/glitch/nous-backend/src/indexer.py", line 34, in indexer
    if not client.schema.exists(source_class):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/glitch/nous-backend/.venv/lib/python3.11/site-packages/weaviate/schema/crud_schema.py", line 318, in exists
    raise RequestsConnectionError(
requests.exceptions.ConnectionError: Checking class existence could not be done.

```

Going through the stack trace i think these are the chunks:

```auto
.....
  File "/usr/lib/python3.11/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

.....
  File "/usr/lib/python3.11/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:
.......
  File "/home/glitch/nous-backend/.venv/lib/python3.11/site-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

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

  File "/home/glitch/nous-backend/.venv/lib/python3.11/site-packages/weaviate/schema/crud_schema.py", line 318, in exists
    raise RequestsConnectionError(
requests.exceptions.ConnectionError: Checking class existence could not be done.

```

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [September 6, 2023, 8:58am UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/2 "2023-09-06T08:58:43Z")

</div>

Hi! Where is your weaviate? Locally or at our WCS?

---

<div class="post-metadata">

**Author:** ![alt-glitch](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/alt-glitch/32/378_2.png) [@alt-glitch](https://forum.weaviate.io/u/alt-glitch)\
**Post date:** [September 6, 2023, 9:45am UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/3 "2023-09-06T09:45:01Z")

</div>

Should have mentioned that!  
I’m using a trial cluster at WCS.

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [September 6, 2023, 3:08pm UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/4 "2023-09-06T15:08:54Z")

</div>

This may be an unstable connection from the client to the server.

Can you try the same code but with a local weaviate? So local client connecting to a local weaviate server?

---

<div class="post-metadata">

**Author:** ![alt-glitch](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/alt-glitch/32/378_2.png) [@alt-glitch](https://forum.weaviate.io/u/alt-glitch)\
**Post date:** [September 6, 2023, 3:40pm UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/5 "2023-09-06T15:40:13Z")

</div>

This code is running on a Google Cloud instance deployed. I don’t think it would have internet connection issues?  
It is deployed on an Asian region though. Could that be a reason?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [September 6, 2023, 6:23pm UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/6 "2023-09-06T18:23:14Z")

</div>

It can be a network/route issue, a WCS (Saas) issue itself, or a Weaviate (Product) issue.

So if we are able to remove the networking part of the equation, run it all local, and still be able to reproduce it, we can have a path to follow.

Also, running it locally, would allow you to have a look at logs, so we can check for any outstanding messages.

Thanks!

---

<div class="post-metadata">

**Author:** ![James\_Tan](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/james_tan/32/2271_2.png) [@James\_Tan](https://forum.weaviate.io/u/James_Tan)\
**Post date:** [September 3, 2024, 4:24am UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/7 "2024-09-03T04:24:50Z")

</div>

i have this issue locally  
opening on browser works fine

ConnectionClosed: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()  
path: “[http://localhost:8086/v1/objects](http://localhost:8086/v1/objects)”

---

<div class="post-metadata">

**Author:** ![James\_Tan](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/james_tan/32/2271_2.png) [@James\_Tan](https://forum.weaviate.io/u/James_Tan)\
**Post date:** [September 3, 2024, 4:30am UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/8 "2024-09-03T04:30:34Z")

</div>

i think i might have found the issue, some kind of data corruption. making a new data store seems to work:

```auto
    - ./data2:/var/lib/weaviate

```

was on ./data:/var/lib/weaviate

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [September 3, 2024, 12:12pm UTC](https://forum.weaviate.io/t/weaviate-server-closes-connection-unexpectedly/626/9 "2024-09-03T12:12:01Z")

</div>

hi @James_Tan !! Welcome to our community 🤗

Thanks for sharing.

Were you able to get any error logs related to this from the server side?

Thanks!
