Connecting to MongoDB using FQDN does not work from local machine

Hello everyone,
really banging my head on this one as I'm of the impression that this has worked not too long ago and I cannot find what change maybe destroyed functionality.

I'm playing around with microservices on my local machine and have set up multiple mongo db containers, services and web applications using docker-compose. Communication inside the created docker network is no problem, but I can no longer connect to the databases from code running on my machine or from the compass application.

Here's my traefik setup and an example configuration of a database container:

name: infra
  services:
  traefik:
    image: traefik:latest
    command:
      - --api.insecure=true
      - --providers.docker
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --entrypoints.mongo-db.address=:27017
      - --providers.file.directory=/etc/traefik/config/dynamic
      - --log.level=DEBUG
    ports:
      - 80:80 # HTTP
      - 443:443 # HTTPS
      - 8080:8080 # Dashboard
      - 27017:27017 # MongoDB
    volumes:
      - //var/run/docker.sock:/var/run/docker.sock # listen to Docker events
      - ./traefik/config/dynamic:/etc/traefik/config/dynamic
      - ./traefik/certs:/certs
    networks:
      - traefik
networks:
  traefik:
    external: true
name: product-configuration
services:
  data:
    image: mongo:latest
    environment:
      - MONGO_INITDB_ROOT_USERNAME=docker
      - MONGO_INITDB_ROOT_PASSWORD=mongopw
    volumes:
      - ${DOCKER_PATHS_MONGO_BASE}\\product-configuration:/data/db
    labels:
      - traefik.tcp.services.data-product-configuration.loadbalancer.server.port=27017
      - traefik.tcp.routers.data-product-configuration.rule=HostSNI(`product-configuration-data.traefik.local`)
      - traefik.tcp.routers.data-product-configuration.entrypoints=mongo-db
      - traefik.tcp.routers.data-product-configuration.service=data-product-configuration
      - traefik.tcp.routers.data-product-configuration.tls=true
      - traefik.tcp.routers.data-product-configuration.tls.passthrough=true
    networks:
      traefik:
        aliases:
          - product-configuration-data.traefik.local
networks:
  traefik:
    external: true

I'm thankful for any input on what I might be missing.

You error description is very vague. What does not work? Can the IP be resolved for the FQDN, can you ping the IP, can you connect to the port? Does the TLS cert include the domain?

Enable and check Traefik dashboard, Traefik debug log and Traefik access log in JSON format.

Hi and thanks for taking the time to respond.

The FQDN ist resolved by a hosts entry to 127.0.0.1 This is all running locally, no cloud infrastructure involved.
Or do you mean the internal container IP? I'd not know how to check that. Connection to the port on the database containers is possible from within docker, but not from the host machine. I cannot say if the connection to traefik already fails as I cannot see any log output that would imply any connections. I'll hvae to tinker with configuration for that I guess.

Is there anythin obviously wrong with the compose files? Everything I've found on the internet so far indicates that this configuration should work

127.0.0.1 within a container is not 127.0.0.1 on the host.