title: Connection refused from docker (in swarm)
body: <p>I have a docker swarm setup with services registered in an overlay network. Comunication between services is working fine however I get a "Connection refused" from one of my services that connects to an external DB. The service is a Java based application (spring boot).</p>
  
  <ul>
  <li>The connection is defined with its IP (jdbc:mysql://192.168.130.141:3306/database?autoReconnect=true)</li>
  <li>I have checked that I can ping the server from the container <code>docker exec -it e093 ping 192.168.130.141</code> gives expected answer</li>
  <li>I have rechecked (4 times) my credentials</li>
  <li>I can connect to the DB from the host</li>
  <li>Host is Ubuntu 16.04.4 LTS</li>
  </ul>
  
  <p>I am running docker 18.03.0-ce and the exact error is</p>
  
  <p><code>java.net.ConnectException: Connection refused (Connection refused)
  at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_151]</code></p>
  
  <p>I'll skip the full stack trace here.</p>
  
  <p>Any help would be greatly appreciated</p>
  
  <p><strong>--EDIT--</strong></p>
  
  <p>Let me clarify that the database is a Galera cluster and the IP I try to connect to is the load balancer (HAProxy) in front of it. I know the setup works as I have other applications connecting to the cluster in this matter as well as the service itself (when not in a docker container).</p>
  
  <p>So, as far as I can tell, my connection informations are correct but it doesn't connect from inside docker services.</p>