# Python client v3 to v4 migration, which connection API to choose?

**URL:** <https://forum.weaviate.io/t/python-client-v3-to-v4-migration-which-connection-api-to-choose/1689>\
**Category:** Support\
**Created:** [March 13, 2024, 1:19am UTC](https://forum.weaviate.io/t/python-client-v3-to-v4-migration-which-connection-api-to-choose/1689 "2024-03-13T01:19:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fairymane](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/fairymane/32/1029_2.png) [@fairymane](https://forum.weaviate.io/u/fairymane)\
**Post date:** [March 13, 2024, 1:19am UTC](https://forum.weaviate.io/t/python-client-v3-to-v4-migration-which-connection-api-to-choose/1689/1 "2024-03-13T01:19:31Z")

</div>

Hello, preciously I setup an Weaviate cluster (on AWS), e.g. accessible via [https://sst-weaviate.ml-stage.motional.com](https://sst-weaviate.ml-stage.motional.com)

when migrating v3 to v4, which proper connection method I should choose?

Previously for v3, the following method works properly

```auto
def get_weaviate_client_v3() -> weaviate.Client:
    cfg = OmegaConf.load(CONFIG_PATH)

    auth_client_secret = hydra.utils.instantiate(cfg.weaviate_client_cfg.auth_client_secret)
    return weaviate.Client(
        url=cfg.weaviate_client_cfg.weaviate_server_url,
        auth_client_secret=auth_client_secret,
        timeout_config=(10, 300),
    )

```

but for V4, where I choose connect\_to\_local()

```auto
def get_weaviate_client_v4():

    cfg = OmegaConf.load(CONFIG_PATH)
    auth_client_secret = weaviate.classes.init.Auth.api_key(cfg.weaviate_client_cfg.auth_client_secret.api_key)

    return weaviate.connect_to_local(
        host=cfg.weaviate_client_cfg.weaviate_server_url,
        auth_credentials=auth_client_secret,
    )

```

But this v4 connection abovr would throw the following error:

> “/opt/homebrew/Cellar/python@3.11/3.11.6\_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py”, line 962, in getaddrinfo  
> for res in \_socket.getaddrinfo(host, port, family, type, proto, flags):  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> socket.gaierror: [Errno 8] nodename nor servname provided, or not known  
> …  
> File “/Users/tao.feng/projects/weaviate-pilot/src/Common.py”, line 55, in get\_weaviate\_client\_v4  
> return weaviate.connect\_to\_local(  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File “/Users/tao.feng/projects/py311/lib/python3.11/site-packages/weaviate/connect/helpers.py”, line 157, in connect\_to\_local  
> return \_\_connect(client)  
> ^^^^^^^^^^^^^^^^^  
> File “/Users/tao.feng/projects/py311/lib/python3.11/site-packages/weaviate/connect/helpers.py”, line 345, in \_\_connect  
> raise e  
> File “/Users/tao.feng/projects/py311/lib/python3.11/site-packages/weaviate/connect/helpers.py”, line 341, in \_\_connect  
> client.connect()  
> File “/Users/tao.feng/projects/py311/lib/python3.11/site-packages/weaviate/client.py”, line 282, in connect  
> self.\_connection.connect(self.\_\_skip\_init\_checks)  
> File “/Users/tao.feng/projects/py311/lib/python3.11/site-packages/weaviate/connect/v4.py”, line 655, in connect  
> super().connect(skip\_init\_checks)  
> File “/Users/tao.feng/projects/py311/lib/python3.11/site-packages/weaviate/connect/v4.py”, line 143, in connect  
> raise WeaviateStartUpError(f"Could not connect to Weaviate:{e}.") from e  
> weaviate.exceptions.WeaviateStartUpError: Could not connect to Weaviate:Connection to Weaviate failed. .

Reading weaviate’s [migration document](https://weaviate.io/developers/weaviate/client-libraries/python/v3_v4_migration), it requires a port for gRPC is open to Weaviate, but since my weaviate cluster is deployed through helm chart, I assume this should already be handled directly, right?

image source:  
image: ‘[cr.weaviate.io/semitechnologies/weaviate:1.24.1](http://cr.weaviate.io/semitechnologies/weaviate:1.24.1)’

Any suggestion on resolving this issue?

### Server Setup Information

- Weaviate Server Version: 1.24.1/helm chart 16.8.4
- Deployment Method: helm chart / K8s
- Multi Node? Number of Running Nodes: 2
- Client Language and Version: Python 3.10 / weaviate-client 4.5.1

---

<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:** [March 13, 2024, 2:38pm UTC](https://forum.weaviate.io/t/python-client-v3-to-v4-migration-which-connection-api-to-choose/1689/2 "2024-03-13T14:38:59Z")

</div>

hi @fairymane !

If you deployed using our helm chart, you need to explicitly enable the grpc service:

> <https://github.com/weaviate/weaviate-helm/blob/853a9c212679931fc750e2550e570fe4ce0e92f9/weaviate/values.yaml#L124>

when you enable it, you will see also the grpc service in k8s

Let me know if this helps 🙂

---

<div class="post-metadata">

**Author:** ![fairymane](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/fairymane/32/1029_2.png) [@fairymane](https://forum.weaviate.io/u/fairymane)\
**Post date:** [March 15, 2024, 11:08pm UTC](https://forum.weaviate.io/t/python-client-v3-to-v4-migration-which-connection-api-to-choose/1689/3 "2024-03-15T23:08:50Z")

</div>

Thanks @DudaNogueira for the hint!  
Now I override and enabled grpcService in my project values.yaml:

> …  
> grpcService:  
> # Set this to true in order to deploy Weaviate gRPC service  
> enabled: true  
> …

And below is the manifest file from the weaviate cluster side:  
weaviate-grpc

> apiVersion: v1  
> kind: Service  
> metadata:  
> annotations:  
> [argocd.argoproj.io/tracking-id:](http://argocd.argoproj.io/tracking-id:) ‘sst-weaviate:/Service:sst-weaviate/weaviate-grpc’  
> [kubectl.kubernetes.io/last-applied-configuration:](http://kubectl.kubernetes.io/last-applied-configuration:) \>  
> {“apiVersion”:“v1”,“kind”:“Service”,“metadata”:{“annotations”:{“[argocd.argoproj.io/tracking-id":“sst-weaviate:/Service:sst-weaviate/weaviate-grpc”},“labels”:{“app.kubernetes.io/managed-by”:“Helm”,“app.kubernetes.io/name”:“weaviate”},“name”:“weaviate-grpc”,“namespace”:“sst-weaviate”},“spec”:{“ports”:[{“name”:“grpc”,“port”:50051,“protocol”:“TCP”,“targetPort”:50051}],“selector”:{“app”:“weaviate”},“type”:"NodePort](http://argocd.argoproj.io/tracking-id%22:%22sst-weaviate:/Service:sst-weaviate/weaviate-grpc%22%7D,%22labels%22:%7B%22app.kubernetes.io/managed-by%22:%22Helm%22,%22app.kubernetes.io/name%22:%22weaviate%22%7D,%22name%22:%22weaviate-grpc%22,%22namespace%22:%22sst-weaviate%22%7D,%22spec%22:%7B%22ports%22:%5B%7B%22name%22:%22grpc%22,%22port%22:50051,%22protocol%22:%22TCP%22,%22targetPort%22:50051%7D%5D,%22selector%22:%7B%22app%22:%22weaviate%22%7D,%22type%22:%22NodePort)”}}  
> creationTimestamp: ‘2024-03-15T17:48:52Z’  
> labels:  
> [app.kubernetes.io/managed-by:](http://app.kubernetes.io/managed-by:) Helm  
> [app.kubernetes.io/name:](http://app.kubernetes.io/name:) weaviate  
> name: weaviate-grpc  
> namespace: sst-weaviate  
> resourceVersion: ‘145458532’  
> uid: 6f99860c-ea37-4b00-8fe5-6d4d126b0913  
> spec:  
> clusterIP: 172.16.34.236  
> clusterIPs:  
> - 172.16.34.236  
> externalTrafficPolicy: Cluster  
> internalTrafficPolicy: Cluster  
> ipFamilies:  
> - IPv4  
> ipFamilyPolicy: SingleStack  
> ports:  
> - name: grpc  
> nodePort: 31397  
> port: 50051  
> protocol: TCP  
> targetPort: 50051  
> selector:  
> app: weaviate  
> sessionAffinity: None  
> type: NodePort  
> status:  
> loadBalancer: {}

However, when I try to create the client by calling `get_weaviate_client_v4()` (code defined above), I still got the same error as put above…

Is there any other trouble shooting method (validating the grpc port and python v4 client) I can try?

---

<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:** [March 18, 2024, 12:53pm UTC](https://forum.weaviate.io/t/python-client-v3-to-v4-migration-which-connection-api-to-choose/1689/4 "2024-03-18T12:53:56Z")

</div>

Hi!

You will now need to expose this port accordingly with an ingress.

here is how you can test your GRPC connection directly, without weaviate client:

# test a weaviate grpc connection

❯ wget [https://raw.githubusercontent.com/grpc/grpc/master/src/proto/grpc/health/v1/health.proto](https://raw.githubusercontent.com/grpc/grpc/master/src/proto/grpc/health/v1/health.proto)  
❯ grpcurl -rpc-header “authorization: Bearer WEAVIATE\_APIKEY” -proto health.proto http://WEVIATE\_URL:WEAVIATE\_GRPC\_PORT grpc.health.v1.Health/Check  
output:  
{  
“status”: “SERVING”  
}
