Got 502 bad gateway with Traefik and Docker swarm

hello guys, i'm new to traefik and i'm having a problem right now i already have a docker swarm cluster in an ec2 instance running and the app is running on port 3000 in the container. when i try to hit the app it says 502 bad gateway it seems that traefik doesn't found the port 3000 in the container for said service.

this is my docker compose

version: '3.3'
services:
  be-ppi-hub-admin:
    image: awsid.dkr.ecr.ap-southeast-1.amazonaws.com/be-ppi-hub-admin:latest-development
    environment:
      ALLOWED_ORIGINS: http://localhost:3000,http://localhost:3001
      LOYALID_BASE_URL: https://portal-staging.loyal.id
      SERVER_TYPE: development
      TZ: Asia/Jakarta
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
     - traefik-public
    logging:
      driver: json-file
    deploy:
      labels:
        traefik.http.routers.be-ppi-hub-admin-https.rule: Host(`apis.oreo.paintpro.co.id`)
          && PathPrefix(`/hub-admin`)
        traefik.http.services.be-ppi-hub-admin.loadbalancer.server.port: '3000'
        traefik.http.routers.be-ppi-hub-admin-http.middlewares: https-redirect
        traefik.http.routers.be-ppi-hub-admin-http.rule: Host(`apis.oreo.paintpro.co.id`)
          && PathPrefix(`/hub-admin`)
        traefik.http.routers.be-ppi-hub-admin-http.entrypoints: http
        swarmpit.service.deployment.autoredeploy: 'true'
        traefik.http.routers.be-ppi-hub-admin-https.entrypoints: https
        traefik.constraint-label: traefik-public
        traefik.http.routers.be-ppi-hub-admin-https.tls: 'true'
        traefik.docker.network: traefik-public
        traefik.enable: 'true'
        traefik.http.routers.be-ppi-hub-admin-https.tls.certresolver: le
      resources:
        reservations:
          cpus: '0.1'
          memory: 100M
        limits:
          cpus: '0.5'
          memory: 1024M
  be-ppi-hub-loyalty:
    image: awsid.dkr.ecr.ap-southeast-1.amazonaws.com/be-ppi-hub-loyalty:latest-development
    environment:
      ALLOWED_ORIGINS: http://localhost:3000,http://localhost:3001
      LOYALID_BASE_URL: https://portal-staging.loyal.id
      SERVER_TYPE: development
      TZ: Asia/Jakarta
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
     - traefik-public
    logging:
      driver: json-file
    deploy:
      labels:
        traefik.http.routers.be-ppi-hub-loyalty-https.tls.certresolver: le
        traefik.http.routers.be-ppi-hub-loyalty-http.middlewares: https-redirect
        traefik.http.routers.be-ppi-hub-loyalty-https.tls: 'true'
        traefik.http.routers.be-ppi-hub-loyalty-https.entrypoints: https
        traefik.http.services.be-ppi-hub-loyalty.loadbalancer.server.port: '3000'
        traefik.http.routers.be-ppi-hub-loyalty-https.rule: Host(`apis.oreo.paintpro.co.id`)
          && PathPrefix(`/hub-loyalty`)
        swarmpit.service.deployment.autoredeploy: 'true'
        traefik.constraint-label: traefik-public
        traefik.http.routers.be-ppi-hub-loyalty-http.entrypoints: http
        traefik.http.routers.be-ppi-hub-loyalty-http.rule: Host(`apis.oreo.paintpro.co.id`)
          && PathPrefix(`/hub-loyalty`)
        traefik.docker.network: traefik-public
        traefik.enable: 'true'
      resources:
        reservations:
          cpus: '0.1'
          memory: 100M
        limits:
          cpus: '0.5'
          memory: 1024M
networks:
  traefik-public:
    external: true

Hi guy,

You could have searched the forum for similar problems, this gets asked every other week.

You could have shared your Traefik static and dynamic config, and docker-compose.yml.

thanks for the input, im new to forums.
i've updated the post with my docker compose. and i'm going to search for similar problems thanks

Bad gateway is usually not about the port, but the target IP can not be reached.

Usually the issue is a name mismatch between docker.network and the real Docker network name, as compose might prefix the network name.

Use docker service / docker network and ls / inspect to check your details.

i've tried to

docker network inspect traefik-public

and the docker service is there

   "a1f49ae9277baad3e4cb7a258a0d04c1d0866eafaf0a48e210a7f28c12757e73": {
                "Name": "be-ppi-hub_be-ppi-hub-loyalty.1.4931vt2j9c7itqxvns0ux0la8",
                "EndpointID": "a7d5e068e8f427c7cd9119b1c677c0728bf6ac36e429fa630b33487c6d1e987a",
                
[details="Summary"]
"MacAddress": "",
                "IPv4Address": "",
[/details]

                "IPv6Address": ""
            },
            "d1b90ed81b08b3a0f631828d0c72d139d6b69268f69aa1ce970dd7c4c5b5eb21": {
                "Name": "be-ppi-hub_be-ppi-hub-admin.1.xhhx5qt3zkmpe9qu2ql6imsni",
                "EndpointID": "d38044831357d9b722c069f0d2aef8d1e03019e9eff921cd100162f6bd6caee3",
               [spoiler]
 "MacAddress": "",
                "IPv4Address": "",
[/spoiler]
                "IPv6Address": ""
            },

Is Traefik also within the same Docker network?