Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Docker Desktop on Windows refuses a published port that nothing seems to use

Your error

Error response from daemon: Ports are not available3 more lines it can show

Fix it fast

Most common cause, 1 of 2

The port falls inside a range Windows reserved for Hyper-V

Publish the container on a host port that lies outside every range in the list.

Fix
docker run -d --name db -p 15432:5432 postgres:18

# compose.yaml
services:
  db:
    ports:
      - "15432:5432"
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

"Ports are not available ... bind: An attempt was made to access a socket in a way forbidden by its access permissions" is WSAEACCES (10013): the port lies in a range Windows excluded, often once Hyper-V is on, or a program holds it exclusively. List excluded ranges with netsh, then remap outside them. Docker Desktop 4.x, Windows 10 and 11.

  • Applies to Docker Desktop 4.x (WSL 2 or Hyper-V backend), Windows 11 23H2 or later, Windows 10 22H2
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Run both commands in an administrator terminal, using the port from the error. The first lists the TCP port ranges Windows keeps away from applications; the second shows whether a process is listening on that port. A range that covers the port with no listener points to the first cause, a LISTENING line with a PID to the second.

Run this first
netsh interface ipv4 show excludedportrange protocol=tcp
netstat -ano | findstr :5432

Then find the line you see in this list and open its fix:

  1. 1The port falls inside a range Windows reserved for Hyper-VOne of the excluded ranges contains the port, and netstat shows no process listening on it
  2. 2Another program has bound the port with exclusive accessnetstat prints a LISTENING line for the port with a PID, and the bind error still says access is forbidden rather than 'Only one usage of each socket address'

What does the error look like?

  • Error response from daemon: Ports are not available
  • bind: An attempt was made to access a socket in a way forbidden by its access permissions.
  • listen tcp :50051: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
  • netstat -ano shows nothing listening on the port Docker refuses

Cause 1 of 2

The port falls inside a range Windows reserved for Hyper-V

You seeOne of the excluded ranges contains the port, and netstat shows no process listening on it

Check

Docker gets the access-forbidden error because Windows has excluded the port from use. Hyper-V is one component that reserves TCP ranges: Microsoft lists port reservation conflicts after enabling Hyper-V among its known issues, and Docker Desktop's Hyper-V backend depends on that feature. Because a reservation is not a listener, Task Manager and netstat show nothing on the port, which is why it looks free.

Check
netsh interface ipv4 show excludedportrange protocol=tcp
netsh interface ipv4 show excludedportrange protocol=tcp store=persistent

Fix

Publish the container on a host port that lies outside every range in the list. The number before the colon is the Windows port; the one after it stays as the container's own port, so only clients on the host switch to the new number.

Fix
docker run -d --name db -p 15432:5432 postgres:18

# compose.yaml
services:
  db:
    ports:
      - "15432:5432"

Verify

The container stays up and Docker reports the new mapping.

Verify
docker port db
Test-NetConnection -ComputerName localhost -Port 15432

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 2

Another program has bound the port with exclusive access

You seenetstat prints a LISTENING line for the port with a PID, and the bind error still says access is forbidden rather than 'Only one usage of each socket address'

Check

Windows also returns WSAEACCES when another application, service or driver has bound the same address with SO_EXCLUSIVEADDRUSE. Map the PID from netstat to its program and to any Windows service that process hosts.

Check
netstat -ano | findstr :5432
tasklist /svc /fi "PID eq 4321"

Fix

When the container takes over that program's job, stop the Windows program or service and set the service to manual start so it cannot grab the port again at the next boot. If both must run, publish the container on another host port.

Fix
# PowerShell as administrator; use the service name tasklist printed
Stop-Service -Name <ServiceName>
Set-Service -Name <ServiceName> -StartupType Manual

Verify

netstat no longer lists a listener on the port, and the container starts with its original mapping.

Verify
netstat -ano | findstr :5432
docker start db

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Give development containers host ports outside the ranges netsh lists on your machine, and keep those ports in the Compose file so the whole team uses them.
  • Check the excluded ranges again after enabling Hyper-V or WSL 2, or after a large Windows update, before blaming the container.
  • Uninstall or set to manual any database or web server installed on Windows that a container now replaces.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Dispatch Pro.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.