Docker says: No connection could be made because the target machine actively refused it
Asked Answered
T

11

26

I was using docker everyday but today a problem occurred without changing anything. I opened docker terminal and tried to start one of my containers. But it gave this error: "No connection could be made because the target machine actively refused it" I am using Windows 10.

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com


admin@samsung MINGW64 ~
$ docker ps
An error occurred trying to connect: Get http://127.0.0.1:2375/v1.22/containers/json: dial tcp 127.0.0.1:2375: connectex: No connection could be made because the target machine actively refused it.

admin@samsung MINGW64 ~
$ docker version
Client:
 Version:      1.10.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   c3959b1
 Built:        Mon Feb 22 22:37:33 2016
 OS/Arch:      windows/amd64
An error occurred trying to connect: Get http://127.0.0.1:2375/v1.22/version: dial tcp 127.0.0.1:2375: connectex: No connection could be made because the target machine actively refused it.
Topsail answered 15/5, 2016 at 3:19 Comment(0)
D
40
  1. Right-click on your PC
  2. Properties
  3. Advanced system settings
  4. Environment Variables
  5. Add new Variable: DOCKER_HOST
    Value: tcp://127.0.0.1:2375
  6. Run Docker Desktop
  7. bottom-right, right-click on Docker-Desktop
  8. Settings
  9. Enable the following option: "Expose daemon on tcp://localhost:2375 without TLS"
Danaedanaher answered 17/3, 2020 at 18:24 Comment(4)
Yesssss! This is the only solution that has worked for me. With or without "Expose daemon" -- it's just the environment variable I needed on the Windows side (already had it set under WSL).Maculate
Awesome solution. For me the "Expose daemon..." checkbox must be ticked, otherwise $ docker container list -a outputs error during connect: Get "http://127.0.0.1:2375/v1.24/containers/json?all=1": dial tcp 127.0.0.1:2375: connectex: No connection could be made because the target machine actively refused it.Lukin
I don't have Docker Desktop. I just want to build idk why it needs to be making TCP connections.Cyrenaic
I had to restart my PC after doing all thisOgbomosho
S
10

I've fixed that by going to Oracle VM VirtualBox Manager (could be searched in start menu), stopping the VM (default in my case) and then running Docker Quickstart Terminal again.

Also, please refer to this answer.

Sherrylsherurd answered 13/3, 2019 at 6:48 Comment(1)
I don't have VirtualBox or Docker Toolbox only DockerCLI.Cyrenaic
F
3

"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port. This may be because it is not running at all or because it is listening on a different port.

Once you start the process hosting your service, try netstat -anb (requires admin privileges) to verify that it is running and listening on the expected port.

Fabien answered 15/5, 2016 at 4:51 Comment(0)
T
2

I was also facing the same issue and even tried by stopping and then restarting the default machine.

Solution: Finally, I restarted my system and then opened the new Docker quickstart terminal. After that I ran "docker run hello-world" again and then it got connected and pulled the hello-world from library/hello-world.

Tarkany answered 26/6, 2017 at 12:3 Comment(1)
I don't have a default machine. Just want to build not run.Cyrenaic
S
2

For me, this was caused by being connected to VPN.

Disconnect from VPN to allow a connection to the local VirtualBox / Docker instance.

Sprayberry answered 11/9, 2020 at 5:42 Comment(0)
I
1

For me it was a proxy setting, Enter Network & internet > proxy Enable "Automatically detect settings"

Inkling answered 7/3, 2023 at 8:12 Comment(0)
H
1

minikube start solved it for me

Hindorff answered 4/9, 2023 at 23:35 Comment(0)
A
0

Fixed this bug with docker desktop through PowerShell, despite the fact that I started up docker desktop my inner process with different name occurred to be stopped:

Status   Name               DisplayName
------   ----               -----------
Stopped  com.docker.service Docker Desktop Service

So I started it with

Start-Service -Name "Docker Desktop Service" 

in PowerShell, and it helped to fix it.

Aperture answered 31/7, 2023 at 11:59 Comment(0)
M
0

Try using

minikube docker-env

It might be used if minikube is your target machine.

Malca answered 30/8, 2023 at 19:46 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Richmal
S
0

The best solution is to run docker diagnostic tool with:

 & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

It will tell you the exact problem.

https://docs.docker.com/desktop/troubleshoot/overview/#self-diagnose-tool

Shortridge answered 13/3 at 9:15 Comment(0)
M
0

I was facing same problem while starting my Kubernetes deploy and found out that every-time your PC/Laptop is restarted you have to run " minikube start " command and for docker just start the docker desktop application

Morez answered 25/6 at 14:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.