Error connect mysql via TCP by traefik

We are running a mysql container on a VM(

e50   mysql:5.7.22   "docker-entr"   8 hours ago   Up 8 hours>3306/tcp   dev-mysql

We wants to connect that mysql container via traefik. We are running traefik on a separate VM (

In our traefik.toml -

defaultEntryPoints = ["http", "https"]

    address = ":3306"

And on dynamic.toml -

      entryPoints = ["mysql"]
      rule = "HostSNI(`*`)"
      service = "database"

        address = ""

But we couldn't connect mysql server. Getting this error -

2013 - Lost connection to MySQL server at 'waiting for initial communication packet', system error: 110 "Connection timed out"

Hello @ipasa

You have inspired me and this morning I deployed MySQL on one of my test clusters and exposed it via Traefik TCP Router. Your configuration seems to be correct because you use HostSNI(*) without TLS and it means that network traffic should correctly forward to the entry point. See that "PR"

However, you didn't post how you deployed Traefik (if it is a container or a standalone instance) but you could first check whether is reachable from the host where Traefik is deployed. Seems that the client didn't reach the MySQL instance because of the timeout, so seems that it is a network connectivity issue.

Please also make sure that you create the appropriate user who can connect to the MySQL server, for test purposes you can create that can be allowed to connect from any host ('newuser'@'%')

Hope that helps,

1 Like