Get Started part 4 connection refused from node on virtual machine

I following the getting started tutorial, but I get stuck at this point. When I try to type on my browser both the IP of the manager and the worker http://192.168.99.100 I get the message 192.168.99.100 or 192.168.99.101 refused to connect.

Both machines are running ok, I deployed the application using the same .yml file as in this part of the tutorial, as instructed. I initialised the swarm on port 2377, as advised, and when I run docker node lsI get the following message:

ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS      ENGINE VERSION
tzyc2gdlt4k4lsvz01d980324 *   myvm1               Ready               Active              Leader              18.09.0
g6pekmpole72tai65josbnew6     myvm2               Ready               Active                                  18.09.0

Which makes me believe everything is running fine.

Also, when I dpeloy the yml file on the manager and then run docker stack ps getstartedlab
I get:

ID                  NAME                  IMAGE                         NODE                DESIRED STATE       CURRENT STATE            ERROR               PORTS
qejmyl4tcx8z        getstartedlab_web.1   alexchris/get-started:part2   myvm1               Running             Running 35 minutes ago                       
cyuvbf8ko1ae        getstartedlab_web.2   alexchris/get-started:part2   myvm2               Running             Running 35 minutes ago                       
on74aelrfygm        getstartedlab_web.3   alexchris/get-started:part2   myvm1               Running             Running 35 minutes ago                       
yod8gys4i298        getstartedlab_web.4   alexchris/get-started:part2   myvm2               Running             Running 35 minutes ago                       
sc77zg8pcs9v        getstartedlab_web.5   alexchris/get-started:part2   myvm2               Running             Running 35 minutes ago         

Which again should be a signal that everything is going fine, but still I can’t connect to the virtual machines.

I tried to run the curl command and this is the output:

curl http://192.168.99.100
curl: (7) Failed to connect to 192.168.99.100 port 80: Connection refused

I tried to tear down the swarm removed the stack, restarted the docker daemon and repeated the process but I had no luck. I am on xubuntu 18.04 bionic and using docker version 18.09.0.

Could anyone help to understand why I cannot reach service?

2 Likes

I am having the same issue with connecting, a solution would be very much appreciated.

same issue here even tried redoing part 4 with no luck

Same here. Stuck on part 4, and got “port 80: connection refused” error. How come the example in the official tutorial not work?

1 Like

Have the same issue!

Same here. Was something changed in the documentation recently?

If you using VirtualBox for nodes.

You have to do configure the port forwarding.

VBoxManage modifyvm "myvm1" --natpf1 allow_web,tcp,,4000,,80
VBoxManage modifyvm "myvm2" --natpf1 allow_web,tcp,,4000,,80

See this. It will be solve your problem :

Yep. Same for me.
I do not think the issue is coming from virtualbox as I am able to deploy my solution using:

docker-machine ssh myvm1 "docker run -d -p '4000:80' rayeshuang/friendlyhello"

And can then access the app through my browser using myvm1 IP and port 4000.

Having the same issue as @elavaud with part 4 and the virtualbox vm. When using docker run f it works with the ip (myvm1), but when using the stack with the mesh networking things stop working. Although doing netstat tulp on myvm1/2 shows that the port is open and that the dockerd is the one listening (as opposed to docker-proxy when doing run).

Manually attaching to a container and issuing a curl returns a response. But nothing is returned when doing curl on the vm itself or from the outside (connection refused).

The two VM’s can connect to each other fine, as they are able to connect to each other when using netcat/nc. And the required ports appear open between the VM’s. Although the issue should not be here as a single node does not work either.

One thing that works is using the (on mac) local docker instance and using it as a single node swarm, with stack deploy + mesh networking.

The issue is well documented here

I downgraded to the boot2docker.iso 18.06.1-CE that you can download here

Destroy your VMs, then create them again specifying the path to your downloaded boot2docker iso with " --virtualbox-boot2docker-url".

For example:

docker-machine create --driver virtualbox --virtualbox-boot2docker-url ~/.docker/machine/cache/boot2dockerv18061CE.iso myvm1

Then start again part 4…

5 Likes

Can confirm that @elavaud solution works.

Cheers for the help. /J

1 Like

The equivalent workaround for Hyper-V VM’s is:

docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" --hyperv-boot2docker-url "https://github.com/boot2docker/boot2docker/releases/download/v18.06.1-ce/boot2docker.iso" myvm1
1 Like

Confirmed, thank you @elavaud. If using VirtualBox, one can also set this environment variable first, then destroy your VMs and re-create them:

VIRTUALBOX_BOOT2DOCKER_URL=https://github.com/boot2docker/boot2docker/releases/download/v18.06.1-ce/boot2docker.iso

PS. If your docker-compose.yml file is set up like this (in Part 3)

ports:
  - "4000:80"

Then the URLs to hit in Part 4 will also need to specify port 4000.

2 Likes

The solution of @elavaud worked for me, thanks. Maybe a short reference in th troubleshooting section of the guide would be useful until the compatibility issue on docker-machine is solved.

Thanks a lot!! Hard to believe I burnt about 3 hours around this issue for nothing.
After re-creating the VMs, I had to docker-machine regenerate-certs in order to fix the env error

Get Started part 4 does not mention using port 4000 in the url (even though docker-compose.yml uses it). So the browser or curl should be able to connect at port 80. Connecting at port 4000 was possible even without the version 18.06.1 - by using boot2docker version 18.09.0 . So the question is how to connect to the VM’s at port 80, as shown in the guide, when the docker-compose.yml specifies the port mapping as ‘4000:80’ ?

Are you able to connect to the VM’s on port 80 or port 4000 ? Did you modify the docker-compose.yml file given in part 3 in any way ?

You have to change the mapping in docker-compose.yml. It is not mentioned in the part-4 doctmentation but if you see the screen cast at the end of page it is showing mapping as - “80:80”.

Now I could get the response but I see the loadbalancing is not working as described in the document. The request is always served by only one container even if I hit any of the 2 available ip addresses of the VMs.

Thanks for pointing out the screen cast. In my case, on ubuntu 16.04, the container ids are changing when I refresh any of the 2 urls.

thank you so so so so much!!. I did like @elavaud suggest and I can finally see the host name rotating. :sweat_smile: