"bind: An attempt was made to access a socket in a way forbidden by its access permissions"
Asked Answered
D

2

6

Say we have frontend and backend containers based on Docker Desktop (for Windows).

Backend container uses port 9001, and the frontend container listens to 9001.

The problem is that port 9001 is already in use by Windows 10 by the Intel driver, and it is impossible to run a container on this port:

Error response from daemon: Ports are not available: listen tcp 0.0.0.0:9001: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

Could you please advise what is the way to handle this port if there is no ability to change it directly from application code?

Dramatize answered 18/5, 2020 at 14:17 Comment(0)
H
4

From another thread, this was the solution on windows for a similar error message:

net stop winnat
docker start container_name
net start winnat
Harrelson answered 30/6, 2023 at 8:20 Comment(1)
For me, "net stop winnat" and "net start winnat" also works for a while.Harrelson
B
2

A couple of ways:

  • When either using a docker run command, specify the host port to use, and set it to something other than 9001. i.e. -p 9002:9001 or Docker Compose, i.e.
ports:
      - '9002:9001'

Then use port 9002 instead of 9001 when accessing the container from the host (Win 10).

  • Use Nginx and set up a reverse proxy, leave the host port empty when starting the container so no external post is opened on the host, and have the reverse proxy pass it over to the container's 9001 port.
Bomarc answered 18/5, 2020 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.