Not able to connect worker nodes to the swarm Connection refused error

+3 votes

I am new to docker swarm. So i have one manager node and two worker nodes. I've used the following command to initialize the docker swarm

docker swarm init --advertise-addr ip_address_of_my_system

I'm trying to join other nodes to this swarm but i'm getting the following error

Error response from daemon: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp 192.168.56.101:2377: connect: connection refused"

where am i going wrong?

Aug 24, 2018 in Docker by Hannah
• 18,540 points
18,659 views
just pass this command - systemctl stop firewalld

4 answers to this question.

+1 vote
Best answer

This definitely has to be a firewall issue. Make sure your port 2377, 7946 and 4789 ports are open.

answered Apr 26, 2019 by Vaidya

selected Apr 26, 2019 by Kalgi
+2 votes

Try changing your docker swarm init command, change it to:

docker swarm init --advertise-addr Ip_address --listen-addr ip_address

then join other worker nodes.

It should work.

answered Aug 24, 2018 by Kalgi
• 52,360 points
If I've to listen to multiple worker nodes, how can I provide those IP address in "init" command?
According to the documentation, listen-addr listens for inbound swarm manager traffic on this address. The default is to listen on 0.0.0.0:2377. It is also possible to specify a network interface to listen on that interface’s address; for example --listen-addr eth0:2377.
Once you initialize the master, workers just follow the master's lead(once workers have joined the cluster obvioulsy), there's no need to add worker's ip address.
Worker's IP address are already added in the master's etc/hosts file.
Thanks alottttt ..................... satyam .

it is working now
Hi Kalgl I am getting the same error after trying this solution
I have one manager setup in one machine and trying to add worker in other machine..

Hey @Hamza, can you post the output of this

docker-machine ls
ID                            HOSTNAME                STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
oxlcvvhtxo93p5um8dj5td7x6 *   linuxkit-00155d018101   Ready               Active              Leader              18.09.0
I simply setup the manager in one pc using command :
docker swarm init

and on other pc used the command returned by the manager and got the error
error response from daemon : rpc error : code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error : desc = "transport: Error while dialing dial tcp 192.168.XXX.XXX:2377 : connect: connection refusederror response from daemon : rpc error : code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error : desc = "transport: Error while dialing dial tcp 192.168.XXX.XXX:2377 : connect: connection refused

Using the latest Docker for windows on both pc's on same LAN

Hey @Hamza, Try issuing appropriate ports through firewalld. Execute the following commands and let me the output:

sudo firewall-cmd --add-port=2376/tcp --permanent  
sudo firewall-cmd --add-port=2377/tcp --permanent  
sudo firewall-cmd --add-port=7946/tcp --permanent  
sudo firewall-cmd --add-port=7946/udp --permanent  
sudo firewall-cmd --add-port=4789/udp --permanent
Hi Kalgi,

Thanks you so much. I enable the port number 2377 and its working fine.
+1 vote

Possible reasons for this error:

  • The port isn't open
  • The port is open on the destination machine, but its backlog of pending connection is full
  • The firewall between the client and server is blocking access
answered Apr 26, 2019 by Jim
0 votes

The same issue happened for me, I used below the steps, then it can work.

#service firewalld stop
#chkconfig firewalld off

or

sudo firewall-cmd --add-port=2376/tcp --permanent  
sudo firewall-cmd --add-port=2377/tcp --permanent  
sudo firewall-cmd --add-port=7946/tcp --permanent  
sudo firewall-cmd --add-port=7946/udp --permanent  
sudo firewall-cmd --add-port=4789/udp --permanent

The post above the command execution then uses the docker join command then it will work.

answered Nov 1, 2020 by Bandhala
• 140 points

Related Questions In Docker

0 votes
1 answer

swarm manager does not connect to nodes docker daemons on AWS

You first need to ssh into the ...READ MORE

answered Aug 24, 2018 in Docker by Nilesh
• 7,060 points
1,703 views
+2 votes
1 answer

Nodes not able to join docker swarm cluster

You need to provide more information like ...READ MORE

answered Sep 26, 2018 in Docker by Kalgi
• 52,360 points
1,838 views
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
3,775 views
0 votes
1 answer

Init could not choose ip address error while doing docker swarm init

First look for the public IP of ...READ MORE

answered Aug 23, 2018 in Docker by Nilesh
• 7,060 points
3,335 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP