# Multiple postgres deployments using different subdns

**URL:** <https://community.traefik.io/t/multiple-postgres-deployments-using-different-subdns/23557>\
**Category:** Traefik v3 (latest)\
**Tags:** tcp, docker-swarm\
**Created:** [July 12, 2024, 1:53pm UTC](https://community.traefik.io/t/multiple-postgres-deployments-using-different-subdns/23557 "2024-07-12T13:53:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mastertenor](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/mastertenor/32/9017_2.png) [@mastertenor](https://community.traefik.io/u/mastertenor)\
**Post date:** [July 12, 2024, 1:53pm UTC](https://community.traefik.io/t/multiple-postgres-deployments-using-different-subdns/23557/1 "2024-07-12T13:53:52Z")

</div>

Hello,

I am trying to use multiple postgres databases using docker swarm. But in the configuration I shared below, if I turn postgre containers into workers, I cannot connect to my postgre servers.

version: '3.8'

services:  
traefik:  
image: 'traefik:v3.1'  
ports:  
- "80:80"  
- "443:443"  
- "5432:5432"  
deploy:  
mode: global  
placement:  
constraints:  
- node.role==manager  
labels:  
- "traefik.enable=true"  
- "traefik.docker.network=traefik-public"  
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"  
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"  
- "traefik.http.routers.traefik-public-http.rule=Host(`traefik.dynhyp.com`)"  
- "traefik.http.routers.traefik-public-http.entrypoints=http"  
- "traefik.http.routers.traefik-public-http.middlewares=https-redirect"  
- "traefik.http.routers.traefik-public-https.rule=Host(`traefik.dynhyp.com`)"  
- "traefik.http.routers.traefik-public-https.entrypoints=https"  
- "traefik.http.routers.traefik-public-https.tls=true"  
- "traefik.http.routers.traefik-public-https.service=api@internal"  
- "traefik.http.routers.traefik-public-https.tls.certresolver=stagingresolver"  
- "traefik.http.services.traefik-public.loadbalancer.server.port=80"  
volumes:  
- "/var/run/docker.sock:/var/run/docker.sock:ro"  
- "traefik-certificates:/certificates"  
command:  
- "--providers.docker"  
- "--providers.docker.exposedbydefault=false"  
- "--providers.swarm.endpoint=unix:///var/run/docker.sock"  
- "--entrypoints.http.address=:80"  
- "--entrypoints.https.address=:443"  
- "--entrypoints.postgres.address=:5432"  
- "[--certificatesresolvers.stagingresolver.acme.email=berk.xxxxx@gmail.com](mailto:--certificatesresolvers.stagingresolver.acme.email=berk.xxxxx@gmail.com)"  
- "--certificatesresolvers.stagingresolver.acme.tlschallenge=true"  
- "--certificatesresolvers.stagingresolver.acme.storage=/certificates/acme.json"  
- "--certificatesresolvers.stagingresolver.acme.caserver=[https://acme-staging-v02.api.letsencrypt.org/directory](https://acme-staging-v02.api.letsencrypt.org/directory)"  
- "--accesslog"  
- "--log"  
- "--api.dashboard=true"  
- "--api"  
networks:  
- traefik-public

customer\_000001\_postgres:  
image: postgres:latest  
environment:  
POSTGRES\_DB: postgres  
POSTGRES\_USER: postgres  
POSTGRES\_PASSWORD: postgres001  
volumes:  
- customer\_000001:/var/lib/postgresql/data  
networks:  
- traefik-public  
deploy:  
mode: global  
placement:  
constraints:  
- node.role==manager  
labels:  
- "traefik.enable=true"  
- "traefik.tcp.routers.customer\_000001\_postgres.entrypoints=postgres"  
- "traefik.tcp.routers.customer\_000001\_postgres.rule=HostSNI(`customer1.example.com`)"  
- "traefik.tcp.routers.customer\_000001\_postgres.tls=true"  
- "traefik.tcp.routers.customer\_000001\_postgres.tls.certresolver=stagingresolver"  
- "traefik.tcp.services.customer\_000001\_postgres.loadbalancer.server.port=5432"

customer\_000002\_postgres:  
image: postgres:latest  
environment:  
POSTGRES\_DB: postgres  
POSTGRES\_USER: postgres  
POSTGRES\_PASSWORD: postgres002  
volumes:  
- customer\_000002:/var/lib/postgresql/data  
networks:  
- traefik-public  
deploy:  
mode: global  
placement:  
constraints:  
- node.role==manager  
labels:  
- "traefik.enable=true"  
- "traefik.tcp.routers.customer\_000002\_postgres.entrypoints=postgres"  
- "traefik.tcp.routers.customer\_000001\_postgres.rule=HostSNI(`customer2.example.com`)"  
- "traefik.tcp.routers.customer\_000002\_postgres.tls=true"  
- "traefik.tcp.routers.customer\_000002\_postgres.tls.certresolver=stagingresolver"  
- "traefik.tcp.services.customer\_000002\_postgres.loadbalancer.server.port=5432"

volumes:  
traefik-certificates:  
driver: local  
driver\_opts:  
type: nfs  
o: addr=10.10.10.131,nfsvers=4  
device: ":/mnt/nfsdisk/certificates"  
customer\_000001:  
driver: local  
driver\_opts:  
type: nfs  
o: addr=10.10.10.131,nfsvers=4  
device: ":/mnt/nfsdisk/customer\_000001/postgres\_data"  
customer\_000002:  
driver: local  
driver\_opts:  
type: nfs  
o: addr=10.10.10.131,nfsvers=4  
device: ":/mnt/nfsdisk/customer\_000002/postgres\_data"

networks:  
traefik-public:  
external: true

* * *

```
deploy:
  mode: replicated
  replicas: 1
  placement:
    constraints:
      - node.role==worker

```

* * *

the error I saw in the traefik logs:

traefik\_traefik.0.yd3iy22ojsa2@ubntsrv01 | 2024-07-12T13:22:40Z ERR Error while dialing backend error="dial tcp 10.0.1.42:5432: i/o timeout"
