Docker Windows error: Port is already allocated

I’ve struggled to resolve an error when trying to start my MongoDB container on a Windows 11 machine. Suddenly after running docker-compose to build and create my containers the MongoDB container failed to start with the following error.

“error starting userland proxy: bind for 0.0.0.0:xxx failed: port is already allocated”

The error is obvious that the port is already allocated, which wasn’t true in my case.

I’ve searched the whole internet for a solution but none was working especially the ones saying to kill the process using that port.

How I resolve it?

The solution is very simple:

  1. Stop all containers
  2. Shutdown docker desktop (if you have one)
  3. Go to your users folder on your Windows machine
  4. Find the folder for the logged in user
  5. Open it and inside find folder “.docker”
  6. Delete it
  7. Restart docker
  8. Run your commands

This is how I resolve this and I hope that I helped you too.

Leave a Reply