Windows: An error occurred trying to connect

Hi forum

I followed all windows install instructions from the website. I also quick-started a machine which doesnt seem to have any issues. When opening a windows command prompt I get the following:

C:\Users\sbuergel>docker version
Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      windows/amd64
An error occurred trying to connect: Get http://localhost:2375/v1.21/version: di
al tcp 127.0.0.1:2375: ConnectEx tcp: No connection could be made because the ta
rget machine actively refused it.

Can anyone help me with the error message on the bottom? I get this when a) having the machine open (I see a blinking linux shell) and b) also when I close that window. I also used the Oracle VM Virtual Box to delete the machine and then use the Docker Quickstart Terminal to create a new machine, the result is the same. Any help would be massively appreciated!

If you open a new shell, you have to tell your docker client how to connect to the docker daemon that is running in the virtualbox VM.

If you open the quickstart terminal, it runs a command that sets the shell environment up so that the docker client knows how to connect.

If you open a new shell, you have to do that step on your own. For windows, you have to specify your shell type. For cmd, run the following and then paste the output back into your cmd shell:

docker-machine env --shell cmd default

or for powershell, just run the following:

docker-machine env --shell powershell default | Invoke-Expression

Cheers!

3 Likes

Actually Iā€™m confronting the same issue but couldnā€™t resolve it as you said. Iā€™m using PowerShell and MSBuild. I first start the default virtual box using docker-machine start default command and then run your commands. But still getting the same error. Can you please help me to resolve this problem.

Docker Toolbox Version 1.10.3 installation on Windows 7/amd64 breaks existing VirtualBox installations. E.g. VBoxManage is missing in the VirtualBox folder.
I get the same error as mentioned above and docker-machine ls tells me ā€œVBoxManage not foundā€¦ā€.

Maybe try deleting and recreating the default machine:

$ docker-machine rm default
$ docker-machine create --driver virtualbox default

Another approach that might work is to open VirtualBox directly, turn off the ā€œdefaultā€ machine, then run Docker Quickstart.

I found these from this docker toolbox issue discussion. Thanks.

Thanks Jeff!
Your suggestion to set the output of ā€œdocker-machine env --shell cmd defaultā€ in the cmd window worked for me.
$ docker-machine env --shell cmd default
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.xxx.xx.xxx:xxxx
SET DOCKER_CERT_PATH=C:\Users\DebanjanBose2.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
REM Run this command to configure your shell:
REM @FOR /f ā€œtokens=*ā€ %i IN (ā€™ā€œC:\Program Files\Docker Toolbox\docker-machine.exeā€ env --shell cmd defaultā€™) DO @%i

This helped, however I still had to run
docker-machine env --shell cmd default
and
@FOR /f "tokens=*" %i IN ('"C:\Program Files\Docker Toolbox\docker-machine.exe" env --shell cmd default') DO @%i
Then it ran OK

Hi,
I didnā€™t help me.

I was getting the below syntax error that I couldnā€™t figure it out. Could you please help me

$ @FOR /f ā€œtokens=*ā€ %i IN (ā€™ā€œc:\Program Files\Docker Toolbox\docker-machine.ex
eā€ env --shell cmd defaultā€™) DO @%i
sh: syntax error near unexpected token `(ā€™

This fixed my problem. Thank you!

I ran across this post because I was having trouble getting my windows docker client to connect (via a TLS secured socket) to an ubuntu-hosted docker daemon. Turns out I had mistyped the port number, so they didnā€™t match. Thought Iā€™d leave this here in order to save somebody else the time.

Thanks, this solved my issue. Btw for anyone who created docker machine manually using create command. replace ā€˜defaultā€™ to name of your machine.