Can't connect to MySQL server: Connection refused

Hi @JamesGreenaway, could you provide more context, aka. the full docker-compose.yml so we can check the configurations?

One thing in particular to check: Traefik infers the port to use for the backend service container from docker's metadatas. But this "automagic" behavior requires the backend (image + container) to expose only 1 port.

If you are using the official mysql Docker image, then this behavior won't work, as 2 ports are exposed: 3306 AND 33060 (I don't know what is the purpose of the port 33060 to be honest).
As it is not possible to know which one to use, so you need to "tell" Traefik that you want 3306:

  • Define a Load Balancer of a Traefik Service named mysql-svc to use the port 3306 by adding the following label to your MySQL container/service: - traefik.tcp.services.mysql-svc.loadbalancer.server.port=3306

  • Associate the service mysql-svc to the router router01-mysql you already defined through your actual labels:
    -traefik.tcp.routers.router01-mysql.service=mysql-svc

If you have any doubt (or if I did any typo) about the syntax, please check the reference documentation here: https://docs.traefik.io/v2.0/reference/dynamic-configuration/docker/

Another thing that is worth trying, while you have only 1 MySQL service behind Traefik: set the HostSNI rule to "catch all" (*) to remove the SNI part from the equation, time for you to validate MySQL initial link:

traefik.tcp.routers.router01-mysql.rule=HostSNI(`*`)

Let us know if you made it !?