PhpStorm (Idea) with Docker: BindException: Address already in use

Intellij Not starting and getting error (BindException: Address already in use) on system with Docker
Short resolution:
net stop winnat
net start winnat

Problem description:
This is /obviously/ not docker's problem (as best I can tell), it's probably not even hyperv's. Commenting here as this seems to be a frustrating and common end of journey for googlers. What follows is at least "one" of the resolutions/explanations.

On one of my machines the dynamic port range was not updated to the "new" start port, and I guess related to a resolved bug in windows has now "exposed" this as a serious problem (e.g.: I couldn't even bind to port 3000 for node dev -- access denied is I think a valid response, but it's not the typical "port in use" root cause).

Current dynamic port config:
> netsh int ipv[46] show dynamicport tcp

Unless you know you've mucked with these settings, and if it doesn't specify 49152 as "Start Port" and is set to 1025, it's not "current". I don't know if there is some kind of migration bug when they were patching this new value or what. Dynamic start port for udp was set correctly for example.

To set it to the current config:
> netsh int ipv[46] set dynamic tcp start=49152 num=16384

(Likely a reboot of your host is required.)

ref: https://support.microsoft.com/en-ca/help/929851/the-default-dynamic-port-range-for-tcp-ip-has-changed-in-windows-vista

While it's bizarre that I only just ran into this issue less than 4 hours ago -- been doing docker/node/go dev for the last few months straight, using docker edge, etc. This appears to have resolved my port exclusion issues (I have no large ranges of reserved ports below 50000 now, previously had 1000 port range exclusions all over the place.)

Install WSL on non-C drive

Open Powershell:

  • Run Set-Location DriveLetter: where DriveLetter is the drive where WSL will be installed
  • Then create a directory for WSL with New-Item WSL -Type Directory
  • Now set location there with Set-Location .\WSL
  • Now download the appx package with Invoke-WebRequest -Uri appx_package_url -OutFile Linux.appx -UseBasicParsing
  • Now we will unpack appx with Copy-Item .\Linux.appx .\Linux2.appx and then Rename-Item .\Linux2.appx -Newname "Linux2.zip" and then Expand-Archive .\Linux2.zip
  • Now Get-Childitem -Filter *.exe and you will find an .exe file named by the distro you downloaded. Run that to setup WSL you are done

List of links of wsl distros here

Extract lib from dll on Windows

1. exports

extract the functions and classes in *.dll by:
$> dumpbin.exe /exports libsample.dll /out:libsample.def

2. function names

edit libsample.def and remove everything except function names (keep C++ name mangling chars). then add EXPORTS as the first line. as:

EXPORTS
?sha1@Hash@polarssl@@SA?AVQByteArray@@ABV3@@Z
?sha1@Hash@polarssl@@SA?AVQByteArray@@ABVQString@@@Z
?sha1@Hash@polarssl@@SA_NABVQString@@0@Z
?sha4@Hash@polarssl@@SA?AVQByteArray@@ABV3@W4TSHA4@12@@Z
?sha4@Hash@polarssl@@SA_NABVQString@@0W4TSHA4@12@@Z
dt_jalali_add_seconds
dt_jalali_diff
dt_jalali_from_daynum
dt_jalali_to_daynum
dt_jalali_to_gregorian
dt_jalali_year

3. make *.lib

run this line depending on architecture:
$> lib.exe /def:libsample.def /machine:arm /out:libsample.lib

source