Docker Troubleshoot issue with taken port
Sometimes when starting a Docker container on Windows and Hyper-V you can get an error that the port is unavailable:
ERROR: for container Cannot start service client:
Ports are not available: listen tcp 0.0.0.0:XYZ: bind:
An attempt was made to access a socket in a way
forbidden by its access permissions.
In case, you cannot see the port being used by any of your local processes, check if Hyper-V is using it.
To do this, you can execute the command: netsh int ipv4 show excludedportrange protocol=tcp
To fix this one time, you can restart winnat: net stop winnat net start winnat
To fix it long term, you can exclude it from Hyper-V with the following command (run PowerShell as admin):
net stop winnat
netsh int ipv4 add excludedportrange protocol=tcp numberofports=1 startport=1433
net start winnat
Commonly used ports:
- ES - 9200
- Cerebro - 9000
- ActiveMQ - 8161 and 61616
- RabbitMQ - 5672 and 15672
- For DB:
- Azure SQL Database - 1433
- Microsoft SQL Server - 1433 (TCP), 1434 (UDP might be required)
- MySQL - 3306
- Oracle - 1521
- PostgreSQL - 5432
From Docker forum and Microsoft
Edit: previous answer required restart of the computer: dism.exe /Online /Disable-Feature:Microsoft-Hyper-V netsh int ipv4 add excludedportrange protocol=tcp startport=1433 numberofports=1 dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
- Previous: PowerShell Retrieve FQDN
- Next: JavaScript ESLint rule disable