[Fix] docker.errors.DockerException Error while fetching server API version

The Error “docker.errors.DockerException: Error while fetching server API version”, is an error that is invoked when you are working on docker and are trying to install a module. Given below is the snippet of the error you might get:

docker.errors.DockerException: Error while fetching server API version

I would like to share with you the steps I took to fix the “docker.errors.DockerException: Error while fetching server API version”

Why “docker.errors.DockerException Error while fetching server API version” Error is Seen?

The error, “docker.errors.DockerException: Error while fetching server API version” is seen most probably because of docker isn’t long running your system.

The error is seen because compose is not being connected to docker via docker socket. The error can also be seen if the right permission is not set.

A detailed solution of the error, “docker.errors.DockerException: Error while fetching server API version” is given below:

How to fix “docker.errors.DockerException Error while fetching server API version” Error?

To fix the error, you will have to make sure that docker is running properly into your system. Run the command “systemctl status docker” to check if docker daemon is running properly and if not, you could run the “systemctl start docker run docker command to start the docker. If your docker is running fine then make sure to set the right permissions.

Once docker is running properly and right permissions are set, error “docker.errors.DockerException Error while fetching server API version” will be fixed.

To fix the error, “docker.errors.DockerException: Error while fetching server API version”, you will have to follow the below mentioned steps:

Step 1: Make sure that docker is Running

First you will have to make sure that docker is running properly in your system. You can run the command mentioned below to check the status of your docker daemon:

systemctl status docker

If docker daemon is not running in your system you will have to run the code mentioned below to get your docker running:

systemctl start docker

This should fix the error “docker.errors.DockerException: Error while fetching server API version”.

Step 2: Set the Right Permission

If while doing the above step you find out that your docker was already running then it is likely that you have a permission issue. You have to set you permission like mentioned below:

sudo chmod 666 /var/run/docker.sock

This should fix the error “docker.errors.DockerException: Error while fetching server API version”.

Conclusion

To fix the error “docker.errors.DockerException: Error while fetching server API version”, you will have to make sure that docker is running in your system.

You can run the command systemctl status docker to check if docker daemon is running and if not you could run to systemctl start docker run docker. If your docker is running make sure to set the right permissions.