Docker-compose fails on Windows with “Error while fetching server API version: (2, ‘CreateFile’, ‘The system cannot find the file specified.’)”

This post was most recently updated on December 1st, 2021.

3 min read.

Once again, I come to you with a surprisingly opaque problem and offer to share my bemusingly simple solution. That should be a dedicated series on my blog – although on second thought, perhaps lobbing 90% of my articles under one tag wouldn’t be helpful… 😁


When running docker-compose up the command would fail, and instead, output a disgustingly long set of what looks like a whole pile of pythons engaging in quantum entanglement would angrily hiss at you if bothered.

It’s not pretty. And it turns out, it’s (at least in this case) also not descriptive at all!

So the errors I got? See below:

Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')

The whole stack trace looks something like below:

Traceback (most recent call last):
   File "docker\api\", line 214, in _retrieve_server_version
   File "docker\api\", line 181, in version
   File "docker\utils\", line 46, in inner
   File "docker\api\", line 237, in _get
   File "requests\", line 543, in get
   File "requests\", line 530, in request
   File "requests\", line 643, in send
   File "requests\", line 439, in send
   File "urllib3\", line 670, in urlopen
   File "urllib3\", line 392, in _make_request
   File "http\", line 1255, in request
   File "http\", line 1301, in _send_request
   File "http\", line 1250, in endheaders
   File "http\", line 1010, in _send_output
   File "http\", line 950, in send
   File "docker\transport\", line 32, in connect
   File "docker\transport\", line 23, in wrapped
   File "docker\transport\", line 72, in connect
   File "docker\transport\", line 52, in connect
 pywintypes.error: (2, 'CreateFile', 'The system cannot find the file specified.')
 During handling of the above exception, another exception occurred:
 Traceback (most recent call last):
   File "docker-compose", line 3, in 
   File "compose\cli\", line 81, in main
   File "compose\cli\", line 199, in perform_command
   File "compose\cli\", line 60, in project_from_options
   File "compose\cli\", line 152, in get_project
   File "compose\cli\", line 41, in get_client
   File "compose\cli\", line 170, in docker_client
   File "docker\api\", line 197, in init
   File "docker\api\", line 221, in _retrieve_server_version
 docker.errors.DockerException: Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')
 [6316] Failed to execute script docker-compose

Augh. The system cannot find the file specified? API version? What is going on…


The solution – at least for me – was simple. But before delving into that, let me describe my setup, so you know whether it’ll apply to you or not!

I run Docker on Windows. It’s configured to run on startup and just do it’s the thing – but occasionally it suddenly needs to gulp down over 10Gb or RAM, then proceed to do nothing, and finally require a restart.

The OS itself is fine, it seems to recover nicely. So this time, I just killed the process, waited for a few minutes, and manually ran docker-compose from PowerShell.

That’s when the error was thrown at me. 😳


I was executing the command from my non-elevated PowerShell window. But that didn’t match how I’ve configured it to run on startup – instead, I needed to run docker-compose from an elevated PowerShell console.

I also realized my Docker Desktop won’t show any of my containers when run non-elevated. I guess that’s kinda obvious, right?

For you, running your stuff elevated (with admin permissions / “as an admin”) or from another user profile, if that’s how it’s configured to run normally, might work.

Stupid? Hey, if it works… 😁


5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments