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 March 3rd, 2023.

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, that 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 the 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 that you know whether it is applicable for you or not!

I run Docker on Windows. It is configured to run on startup and just do its thing – but occasionally it suddenly needs to gulp down over 10Gb or RAM, then proceed to do nothing, and finally requires 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 have configured it to run on startup – instead, I needed to run docker-compose from an elevated PowerShell console.

And to be fair, you’d do well to also make sure Docker Desktop is actually running. The service won’t, at least by default, start unless the application itself is started. (This was a very valid point made by multiple people in the comments-section below – THANKS!)

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 2 votes
Article Rating
Notify of

most voted
newest oldest
Inline Feedbacks
View all comments