简体   繁体   中英

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

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.

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

只需在您的计算机上打开 Docker Desktop

sudo chmod 666 /var/run/docker.sock

这对我有用

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

Make sure your docker is actually running on your machine. You can use this post: How to check if the docker engine and a docker container are running?

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

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.

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.

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.

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/

Very likely means that your docker desktop app (at least in development) was not running. For me, opening the Mac app did it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM