title: How to setup mongodb with traefik and docker compose?
body: <p>I have a docker swarm cluster where I'm trying to setup mongodb using traefik. Traefik is working with my other services, but I'm having trouble with mongo. I try to connect with mongo compass and I usually get a &quot;connect ECONNREFUSED&quot; error. I'm not sure what I'm missing to get this working.</p>
  <p>Traefik docker compose:</p>
  <pre><code>&quot;--entrypoints.mongo.address=:27017&quot;
  </code></pre>
  <p>Mongo docker compose:</p>
  <pre><code>version: '3.8'
  
  networks:
    default:
      external: true
      name: proxy
      
  services:
    mongo:
      image: mongo:5.0.6
      volumes:
        - /data/mongo:/data/db
      deploy:
        labels:
          - 'traefik.enable=true'
  
          - 'traefik.tcp.routers.mongo.rule=HostSNI(`example.com`)'
          - 'traefik.tcp.routers.mongo.entrypoints=mongo'
          - 'traefik.tcp.routers.mongo.tls=true'
          - 'traefik.tcp.services.mongo.loadbalancer.server.port=27017'
  </code></pre>