# TCP Service for Mosquitto not connecting to pod

**URL:** <https://community.traefik.io/t/tcp-service-for-mosquitto-not-connecting-to-pod/10462>\
**Category:** Traefik v2\
**Tags:** docker, tcp\
**Created:** [April 26, 2021, 10:01pm UTC](https://community.traefik.io/t/tcp-service-for-mosquitto-not-connecting-to-pod/10462 "2021-04-26T22:01:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![y2kdread](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@y2kdread](https://community.traefik.io/u/y2kdread)\
**Post date:** [April 26, 2021, 10:01pm UTC](https://community.traefik.io/t/tcp-service-for-mosquitto-not-connecting-to-pod/10462/1 "2021-04-26T22:01:41Z")

</div>

Hi Everyone,

I am trying to expose a MQTT endpoint to the internet using Traefik. When I expose the service and and try to access it using MQTT explorer, I get a `connection refused` error. When looking at the service in the Traefik dashboard, I found that my TCP Service is failing to connect to the pod:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/0/0dd54a8c281d4950227356d20c23703942b51867.png)

To verify that my container is configured correctly, I went to my docker server and was able to telnet into that IP/Port with no issues. I've tried to do a bunch of troubleshooting and I am unable to figure out why this is failing. I've provided the below code to see if I can get a second set of eyes to figure out why this is failing:

**Traefik configuration in docker compose**

```auto
  traefik:
    image: traefik:v2.4
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - public_facing
    ports:
      - "80:80"
      - "443:443"
      - "8883:8883"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ${DOCKER}/traefik/acme.json:/acme.json
      - ${DOCKER}/traefik/users:/users:ro
    command:
      - "--api=true"
      - "--api.dashboard=true"
      - "--providers.docker=true"
      - "--providers.docker.endpoint=unix:///var/run/docker.sock"
      - "--providers.docker.exposedbydefault=false"
      #- "--log.level=DEBUG"
        # Entrypoints 
      - "--entrypoints.http.address=:80"
      - "--entrypoints.https.address=:443"
      - "--entrypoints.mqtt.address=:8883"
      - "--entrypoints.websocket.address=:9001"
        # Redirect http to https
      - "--entrypoints.http.http.redirections.entrypoint.to=https"
      - "--entrypoints.http.http.redirections.entrypoint.scheme=https"
        # Let's encrypt configuration
      - "--certificatesresolvers.lazyresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.lazyresolver.acme.email=fake@email.com"
      - "--certificatesresolvers.lazyresolver.acme.storage=/acme.json"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=https"
      - "traefik.http.routers.traefik.rule=Host(`traefik.${DOMAINNAME}`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.middlewares.traefik-auth.basicauth.usersfile=/users"
      - "traefik.http.routers.traefik.tls.certresolver=lazyresolver"

```

**Mosquitto configuration in docker compose**

```auto
  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: unless-stopped
    ports:
      - 1883:1883
      - 8884:8883
      - 9001:9001
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKER}/mosquitto/data:/mosquitto/data
      - ${DOCKER}/mosquitto/config:/mosquitto/config
      - ${DOCKER}/mosquitto/log:/mosquitto/log
    environment:
      - TZ=${TZ}
    labels:
      - "traefik.enable=true"
      - "traefik.tcp.routers.mqtt.rule=HostSNI(`*`)"
      - "traefik.tcp.routers.mqtt.tls.certresolver=lazyresolver"
      - "traefik.tcp.services.mqtt.loadbalancer.server.port=8883"
      - "traefik.tcp.routers.mqtt.entrypoints=mqtt"
      - "traefik.docker.network=public_facing"

```

I have no clue what I am missing as this seems like it should be straightforward.

Does anyone have ideas?
