Docker-compose up : Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))

PhpDockerApiServerDocker Compose

Php Problem Overview


I am trying to do the docker-compose up command in my terminal. First I navigate to the file directory where I find a docker-compose.yaml. Then I write the command. The Server is on Port 80. I get the following error:

Traceback (most recent call last):
      File "site-packages/docker/api/client.py", line 205, in _retrieve_server_version
      File "site-packages/docker/api/daemon.py", line 181, in version
      File "site-packages/docker/utils/decorators.py", line 46, in inner
      File "site-packages/docker/api/client.py", line 228, in _get
      File "site-packages/requests/sessions.py", line 543, in get
      File "site-packages/requests/sessions.py", line 530, in request
      File "site-packages/requests/sessions.py", line 643, in send
      File "site-packages/requests/adapters.py", line 498, in send
    requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "docker-compose", line 3, in <module>
      File "compose/cli/main.py", line 67, in main
      File "compose/cli/main.py", line 123, in perform_command
      File "compose/cli/command.py", line 69, in project_from_options
      File "compose/cli/command.py", line 132, in get_project
      File "compose/cli/docker_client.py", line 43, in get_client
      File "compose/cli/docker_client.py", line 170, in docker_client
      File "site-packages/docker/api/client.py", line 188, in __init__
      File "site-packages/docker/api/client.py", line 213, in _retrieve_server_version
    docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))
    [12728] Failed to execute script docker-compose

The first error shows up two times then the second.

Php Solutions


Solution 1 - Php

Add your user to docker group and try again.

sudo gpasswd -a $USER docker
newgrp docker

If you still have the problem, you may try after logging out and login back, or reboot. Or simply do:

sudo su $USER

Note: this may also happens if docker is not running on your machine. For linux with sytemd service manager, you could verify using command:

systemctl status docker.service

Solution 2 - Php

just open Docker Desktop on your computer

Solution 3 - Php

sudo chmod 666 /var/run/docker.sock

This worked for me

Solution 4 - Php

I had the same issue and error message. In my case i had to start and enable docker service.

systemctl start docker
systemctl enable docker

Solution 5 - Php

Make sure your docker is actually running on your machine. You can use this post: https://stackoverflow.com/questions/43721513/how-to-check-if-the-docker-engine-and-a-docker-container-are-running

Solution 6 - Php

Solution: This means you haven’t started your docker service!

First, try to start it using

1.sudo systemctl start docker

2.sudo service docker start

3.sudo /etc/init.d/docker restart

For More Info see this docs:here

Solution 7 - Php

To add clarity to Zstack's answer.

I encountered this issue while trying to setup Ansible AWX on Ubuntu 20.04

> fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))"} ...ignoring

Here's how I fixed it:

The issue was caused because I had not added my current user to the docker group.

Create the docker group if it does not already exist.

sudo groupadd docker

Add your user to the docker group.

sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

Verify that you can run docker commands without sudo.

docker ps

That's all.

Solution 8 - Php

I had the same error after system and Docker updates on macOS Big Sur 11.1. I was also unable to run Docker Desktop, so I've checked the option open at login and simply restarted the system.

Solution 9 - Php

This problem occurs due to docker user has no right access ,

After giving the right permissions and reconnecting to the server should solve the issue,

You can create the docker user if not exist

> sudo groupadd docker

Add docker user to user group

> usermod -aG docker $USER

Then reconnect to the server, it should work.

For more information this link is usefull : https://docs.docker.com/engine/install/linux-postinstall/

Solution 10 - Php

I tried almost all the solutions above but for some reason what worked for me was sourcing the bashrc file:

source ~/.bashrc.

After this the error went away.

Solution 11 - Php

Add your user to docker group and try again.

sudo gpasswd -a $USER docker newgrp docker If you still have the problem, you may try after logging out and login back, or reboot. Or simply do:

sudo su $USER Note: this may also happens if docker is not running on your machine. For linux with sytemd service manager, you could verify using command:

systemctl status docker.service

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionblackSwan566View Question on Stackoverflow
Solution 1 - PhpZstackView Answer on Stackoverflow
Solution 2 - PhpslideWXYView Answer on Stackoverflow
Solution 3 - PhpAbdulhakimView Answer on Stackoverflow
Solution 4 - PhpkoolwithkView Answer on Stackoverflow
Solution 5 - PhpbisamovView Answer on Stackoverflow
Solution 6 - Phpcng.buffView Answer on Stackoverflow
Solution 7 - PhpPromise PrestonView Answer on Stackoverflow
Solution 8 - PhpmproView Answer on Stackoverflow
Solution 9 - PhpMurad ShukurluView Answer on Stackoverflow
Solution 10 - Phpanosha_rehanView Answer on Stackoverflow
Solution 11 - PhpBuff cngView Answer on Stackoverflow