# Connection\_params for docker configuration

**URL:** <https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562>\
**Category:** Support\
**Created:** [February 24, 2024, 6:10pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562 "2024-02-24T18:10:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Gordon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dan_gordon/32/659_2.png) [@Dan\_Gordon](https://forum.weaviate.io/u/Dan_Gordon)\
**Post date:** [February 24, 2024, 6:10pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/1 "2024-02-24T18:10:05Z")

</div>

I had weaviate in the same docker-compose.yml file as my flask files and I was able to connect to it via this:

```auto
connection_params=weaviate.connect.ConnectionParams.from_params(
            http_host="weaviate",
            http_port="8060",
            http_secure=False,
            grpc_host="weaviate",
            grpc_port="50051",
            grpc_secure=False,
        ),

```

I just moved the weaviate instance to its own docker but still on the same machine. Now I can’t connect to it. I have tried ‘localhost’, ‘172.29.0.2’, ‘127.0.0.1’, ‘0.0.0.0’, ‘host.docker.internal’, and ‘[myserver.com](http://myserver.com)’

What am I missing? Do I need to set up a reverse proxy now in nginx?

- Weaviate Server Version: 1.23.9
- Deployment Method: Docker
- Multi Node? 1
- Client Language and Version: Python 4.4.4

---

<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:** [February 25, 2024, 10:54am UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/2 "2024-02-25T10:54:43Z")

</div>

Hi! Welcome to our community 🤗

Can you share your docker compose?

Unless you have changed the default port in the command of you Weaviate service, you should use 8080 for the connection port.

Let me know if that helps.

---

<div class="post-metadata">

**Author:** ![Dan\_Gordon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dan_gordon/32/659_2.png) [@Dan\_Gordon](https://forum.weaviate.io/u/Dan_Gordon)\
**Post date:** [February 25, 2024, 11:18pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/3 "2024-02-25T23:18:14Z")

</div>

It’s not the port that is the problem, it’s the host, what host do I use to connect from one docker to the other on the same machine?

weaviate:  
command:  
- --host  
- 0.0.0.0  
- --port  
- ‘8060’  
- --scheme  
- http  
image: semitechnologies/weaviate:1.23.9  
ports:  
- 8060:8060  
- 50051:50051  
volumes:  
- weaviate\_data:/var/lib/weav  
restart: on-failure:0  
environment:  
QUERY\_DEFAULTS\_LIMIT: 25  
AUTHENTICATION\_ANONYMOUS\_ACCESS\_ENABLED: ‘true’  
PERSISTENCE\_DATA\_PATH: ‘/var/lib/weav’  
DEFAULT\_VECTORIZER\_MODULE: ‘none’  
ASYNC\_INDEXING: ‘true’  
CLUSTER\_HOSTNAME: ‘node1’

volumes:  
weaviate\_data

---

<div class="post-metadata">

**Author:** ![exsbandit](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/exsbandit/32/1027_2.png) [@exsbandit](https://forum.weaviate.io/u/exsbandit)\
**Post date:** [February 26, 2024, 11:15am UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/4 "2024-02-26T11:15:36Z")

</div>

I already use like this and worked

```auto
weaviate:
    container_name: con-project-weaviate
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: semitechnologies/weaviate:1.23.10
    ports:
    - 8080:8080
    - 50051:50051
    volumes:
    - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    env_file:
      - ./python-api/.env
    environment:
      #OPENAI_APIKEY: $OPENAI_API_KEY
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      DEFAULT_VECTORIZER_MODULE: 'text2vec-openai'
      ENABLE_MODULES: 'text2vec-openai'
      CLUSTER_HOSTNAME: 'node1'
volumes:
  weaviate_data:

```

---

<div class="post-metadata">

**Author:** ![Dan\_Gordon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dan_gordon/32/659_2.png) [@Dan\_Gordon](https://forum.weaviate.io/u/Dan_Gordon)\
**Post date:** [February 26, 2024, 9:00pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/5 "2024-02-26T21:00:35Z")

</div>

What did you use for host name in the following?

connection\_params=weaviate.connect.ConnectionParams.from\_params(  
http\_host=“weaviate”,  
http\_port=“8060”,  
http\_secure=False,  
grpc\_host=“weaviate”,  
grpc\_port=“50051”,  
grpc\_secure=False,  
),

---

<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:** [February 27, 2024, 12:26am UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/6 "2024-02-27T00:26:52Z")

</div>

Hi @Dan_Gordon!

If your client is running in the same network where Weaviate is within docker, and the service name is called weaviate, this should be what you have to use.

Otherwise, if your client is running outside of docker, you should use the IP or the hostname where the ports are binded.

Let me know if this helps.

Thanks!

---

<div class="post-metadata">

**Author:** ![exsbandit](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/exsbandit/32/1027_2.png) [@exsbandit](https://forum.weaviate.io/u/exsbandit)\
**Post date:** [February 27, 2024, 6:23am UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/7 "2024-02-27T06:23:07Z")

</div>

You must use network gateway ip from there,  
@Dan_Gordon  
-docker network ls  
find your network for that project, then  
-docker inspect network (networkaddress)  
when the data network shown at the top of u can find network gateway IP  
when you use that ip form the weaviatehost its works fine  
it seems like that ([http://172.12.0.1:8080](http://172.12.0.1:8080))

---

<div class="post-metadata">

**Author:** ![divisionby0](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/divisionby0/32/1476_2.png) [@divisionby0](https://forum.weaviate.io/u/divisionby0)\
**Post date:** [May 11, 2024, 10:18pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/8 "2024-05-11T22:18:12Z")

</div>

Hi, I too am trying to connect to a Weaviate docker instance.

```auto
connection_params = weaviate.connect.ConnectionParams(
        scheme="http",
        host="localhost",
        port=8080,
        grpc_host="weaviate",
        grpc_port="50051",
        grpc_secure=False,
    )
client = weaviate.connect.Connection(connection_params)

```

but I get this error:

```auto
    connection_params = weaviate.connect.ConnectionParams(
  File "/Users/anand/miniconda3/envs/cerebro/lib/python3.9/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__. __pydantic_validator__.validate_python(data, self_instance= __pydantic_self__ )
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ConnectionParams
http
  Field required [type=missing, input_value={'scheme': 'http', 'host'...', 'grpc_secure': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
grpc
  Field required [type=missing, input_value={'scheme': 'http', 'host'...', 'grpc_secure': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing

```

---

<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:** [May 12, 2024, 1:56pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/9 "2024-05-12T13:56:09Z")

</div>

hi @divisionby0 !

Can you try the syntax as described here?

> **[Python | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/client-libraries/python#python-client-v4-explicit-connection)**
>
> Overview

For instance:

```auto
import weaviate
from weaviate.connect import ConnectionParams
from weaviate.classes.init import AdditionalConfig, Timeout
import os

client = weaviate.WeaviateClient(
    connection_params=ConnectionParams.from_params(
        http_host="localhost",
        http_port="8080",
        http_secure=False,
        grpc_host="localhost",
        grpc_port="50051",
        grpc_secure=False,
    ),
    auth_client_secret=weaviate.auth.AuthApiKey("secr3tk3y"),
    additional_headers={
        "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
    },
    additional_config=AdditionalConfig(
        timeout=Timeout(init=2, query=45, insert=120), # Values in seconds
    ),
)

client.connect() # When directly instantiating, you need to connect manually

```

Let me know if this works.

Thanks!

---

<div class="post-metadata">

**Author:** ![Gene\_Mc](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/gene_mc/32/1095_2.png) [@Gene\_Mc](https://forum.weaviate.io/u/Gene_Mc)\
**Post date:** [June 25, 2024, 7:47pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/10 "2024-06-25T19:47:17Z")

</div>

Short answer - YES, the explicit connection worked…

I tried many things to get inter-container Docker networking to function. I had even found the same web page as above, but stopped at [v4-client-helper-functions](https://weaviate.io/developers/weaviate/client-libraries/python#python-client-v4-helper-functions) just above the “explicit” connection section you highlighted. The `weaviate.connect_to_custom()` looks almost identical to the explicit function, but of course it fails…???

Is there an explanation as to why we need to use an explicit connection in the case of Docker? And why connect\_to\_custom() will not work?

I’m glad it’s working, but this was hard to figure out…at least for me…

---

<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:** [June 25, 2024, 8:42pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/11 "2024-06-25T20:42:05Z")

</div>

Hi @Gene_Mc !

This is because it will all depend on how you have deployed Weaviate in docker.

For example, it can be exposed on a different port, or a different hostname. It can be secured or insecured.

So you need to “pair” your connection parameters with how you have deployed Weaviate.

On the case of connecting a client that is running on a container, to Weaviate that is also running on a container, usually setting the host to weaviate (or whatever service name you set in your docker compose), http\_port to 8080, grpc\_port to 50051, all unsercure (grpc\_secure=False, http\_secure=False) should work.

Of course, considering that both services are in the same docker compose or at the same network and has connectivity between them.

Let me know if this works.

If you have any issues, let us know 🙂

---

<div class="post-metadata">

**Author:** ![Gene\_Mc](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/gene_mc/32/1095_2.png) [@Gene\_Mc](https://forum.weaviate.io/u/Gene_Mc)\
**Post date:** [June 25, 2024, 9:18pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/12 "2024-06-25T21:18:17Z")

</div>

I think my question made no sense before…

Option1, this did not work when I tried it initially:

```auto
client = weaviate.connect_to_custom(
    http_host="weaviate",
    http_port="8080",
    http_secure=False,
    grpc_host="weaviate",
    grpc_port="50051",
    grpc_secure=False,
)

```

Option 2, but this did work:

```auto
client = weaviate.WeaviateClient(
    connection_params=ConnectionParams.from_params(
        http_host="weaviate",
        http_port="8080",
        http_secure=False,
        grpc_host="weaviate",
        grpc_port="50051",
        grpc_secure=False,
    ),
)

client.connect() 

```

Of course had I tried a bunch of things in between, and when I went back and tried the first one, it worked too!

So let me ask a different question… under which circumstances would I use option 2 instead of option 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:** [June 26, 2024, 12:38pm UTC](https://forum.weaviate.io/t/connection-params-for-docker-configuration/1562/13 "2024-06-26T12:38:03Z")

</div>

Hi!

They are basically the same code. `connect_to_custom` will instantiate a `WeaviateClient`, connect and return the (hopefully) connected client.

Check here:

> <https://github.com/weaviate/weaviate-python-client/blob/cbedf2a5fb5c84fe0ec658f77fab41bd226ff0de/weaviate/connect/helpers.py#L378>

I have tried both of those code you used from the host, using a clean docker compose, and replacing `weaviate` by localhost and they worked.

So if both your containers has connectivity (same network), it should also work 🤔
