Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks
worldzhang2010 opened this issue Oct 28, 2020 · 31 comments

Comments

@worldzhang2010
Copy link

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID:

Expected behavior

Actual behavior

Information

  • Windows Version:
  • Docker Desktop Version:
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM:

Steps to reproduce the behavior

  1. docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:4449: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
@adi-ch2019
Copy link

This is because your IIS or some other server is already running on port 4449.
Try this and it should work.

@adi-ch2019
Copy link

remove all instances of apps on IIS. Restart IIS by 'iisreset'
This worked

@satishautade
Copy link

I have encountered the same issue. I probably don't understand much of the ports ranges in Windows 10 but I was able to make it work when I used -P option for docker run command. Basically letting docker pick a port that works.
Here is the full command that worked for me
docker run -d -P --name docker-tutorial docker101tutorial
then run docker ps to check which local port you should use in the URL.
docker ps

@cdalexndr
Copy link

In my case, nestat -aon showed that port was not in use, but running netsh int ipv4 show excludedportrange protocol=tcp showed a port exclusion range that included my port.

I have no ideea who and why is excluding the port range, and have opened a stackexchange question

@cdalexndr
Copy link

Duplicate of #3171

@cdalexndr
Copy link

Changing the dynamic port range with netsh int ipv4 set dynamic tcp start=49152 num=16384 (source) and after a restart excluded port ranges are ok.

@smoothumut
Copy link

stop iis, then run docker image,, then you can restart the iis if you want without a problem

@midnightelf
Copy link

midnightelf commented Feb 9, 2021

may be netcfg -d and restart ?
alose try this
net stop winnat
docker-compose up ...
net start winnat

@michael-freidgeim-webjet

to stop IIS use either
iisreset /STOP
(From https://stackoverflow.com/questions/22084561/difference-between-iisreset-and-iis-stop-start-command )
or
net stop "W3SVC"
(From https://stackoverflow.com/questions/49222911/how-to-fully-stop-iis-using-command-line-bat-file )

@revegnay
Copy link

revegnay commented Apr 9, 2021

may be netcfg -d and restart ?
alose try this
net stop winnat
docker-compose up ...
net start winnat

It's working for me.
thinks!

@heyuanfly
Copy link

in my case,the task manager show that a system process is occupy port 80.

just open service list and stop the world wide web service,then everything will be ok

the name of service maybe a little different, but should include keywords :world wide web

@newcanopies
Copy link

@heyuanfly I found the same system process listed in WindowsDefenderFirewall,

but none of services starting with letter w matched the keywords in TaskManager .. any idea how to trace the service via TaskManager process ID?

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@naikrovek
Copy link

naikrovek commented Jul 29, 2021

@newcanopies In Windows, use netstat -aon to match the listening port to the PID of the process, which is also visible in Task Manager (once you turn that column on.)

I get this issue and it is definitely not a "port in use" error. Nothing else is using the port. I can try any number of other ports, and most of them will fail, and then suddenly one port will work. Every port I tried previously will continue to fail.

This is a problem with Windows, and I think Docker is exposing this problem. If I bind ports in Docker in WSL 2 to listen only on the WSL 2 eth0 interface address, instead of the default 0.0.0.0, binding always seems to work fine. I'm fairly confident that it has something to do with Docker and WSL 2 and how Windows forwards "localhost" ports on WSL 2 to the hosting Windows machine, so that "localhost" addresses on Windows forward to WSL 2, if they are exposed to WSL 2's localhost interface.

/remove-lifecycle stale

@OfficialDarkComet
Copy link

to stop IIS use either
iisreset /STOP
(From https://stackoverflow.com/questions/22084561/difference-between-iisreset-and-iis-stop-start-command )
or
net stop "W3SVC"
(From https://stackoverflow.com/questions/49222911/how-to-fully-stop-iis-using-command-line-bat-file )

Michael solution worked for me.

S net stop "W3SVG"
$ docker run -d -p 80:80 docker/getting-started
$ net start "W3SVC"

@naikrovek
Copy link

For me, it was winnat holding a giant pile of port reservations. Obviously you can't use a port if something else reserved it, and winnat had an insanely large number of reserve port ranges. Clearing that and rebooting fixed everything for me.

this comment on another bug about this issue contains the 4 commands I ran to fix this. This broke networking in WSL 2 for me, so I needed to reboot, but after I came back up, all was well.

Best of luck!

@MoroccanGeek
Copy link

may be netcfg -d and restart ?
alose try this
net stop winnat
docker-compose up ...
net start winnat

It's working for me. thinks!

Worked for me as well. thank you

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@bschwerin
Copy link

/remove-lifecycle stale

@alexx855
Copy link

netcfg -d and restart ?

did the trick for me

@majidshakeelshawl
Copy link

Open IIS Software and on right side Click Stop and run the docker command (docker run) again.

This Worked for me.

@namwanza
Copy link

namwanza commented May 8, 2022

Well, the suggestions above did not solve my problem,
I had to go to docker-composer.yml file in my laravel project and edited these two lines for the port

from '${APP_PORT:-80}:80' to '${APP_PORT:-89}:80'
and
${HMR_PORT:-808-}:8080' ----> '${HMR_PORT:-8084}:8080'
and everything worked like charming.

@zeeshan-github-project
Copy link

@namwanza
why cannot we change mysql FORWARD_DB_PORT number in same docker-composer.yml file beacuse mysql is not running in my laravel project

@narkhis
Copy link

narkhis commented Jun 28, 2022

for me the solution was to stop iis service , it work .

@aknessy
Copy link

aknessy commented Sep 11, 2022

Encountered something similar very recently while attempting to power up Laravel sail. Running docker ps I discovered port 3306 was already up for a local mysql installation. Doing net stop winnat and running ctrl+alt+del to start the task manager and stop the mysqld instance and then running net start winnat before ./vendor/bin/sail up solved it.

@docker-robott
Copy link
Collaborator

There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

@devluist
Copy link

devluist commented Jan 8, 2023

Hi, I found a solution, but not the best to be honest...

  • net stop winnat and restarting commands did not solve my issue completely, since it turned off my ability to connect to the web from my wsl2 ubuntu console (try ping google.com and you will get timeout)

  • also changing the port in the docker compose file or the run command is annoying

The real problem is that Docker and hyper-v are storing a bunch of ports on windows, to check that run in a powershell terminal
netsh int ipv4 show excludedportrange protocol=tcp

so, if the port you try to use is in any of those ranges you are in trouble

1- one solution is to keep asking every restart of your machine what ports are available (ranges are reserved on every startup)
so run the netsh command provided above and pick a port that is not on the ranges of that list

2- or you could reserve the ports to avoid checking every time, pick a range that you see empty, and modify this command accordingly, for example, this will reserve ports from 10000 to 10999:

netsh int ipv4 add excludedportrange protocol=tcp startport=10000 numberofports=1000 store=persistent

@wnarutou
Copy link

wnarutou commented Mar 7, 2023

may be netcfg -d and restart ? alose try this net stop winnat docker-compose up ... net start winnat

worked for me, thx

@tharoosha
Copy link

This happens if you have already run a service on port 4449
you can check which service this currently running that port and disable it.
netstat -aon | findstr :4449 to find the service running on the 4449 port and go to task manager and disable it.

@naikrovek
Copy link

"port already in use" or something like that is usually the error you will see when there is something already using that port and won't let go of it. winnat is usually what causes the socket access error.

the winnat solutions listed in this issue work.

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

/lifecycle locked

@docker docker locked and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests