“Error starting userland proxy: Bind for unexpected error Permission denied” error when debugging ASP.Net Core application

If you get an “Error starting userland proxy: Bind for unexpected error Permission denied” error, when debugging your ASP.Net Core application in Docker, then run the following command to find the excluded ports range, being used by different applications:

netsh int ip show excludedportrange protocol=tcp

image

I then change my launchSettings.json file to use a port that is not reserved

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "//localhost:50504",
      "sslPort": 44392
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Scrubber": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "//localhost:5001;//localhost:5000"
    },
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
      "environmentVariables": {
        "ASPNETCORE_URLS": "//+:443;//+:80",
        "ASPNETCORE_HTTPS_PORT": "44393"
      },
       "httpPort": 54558,
      "useSSL": true,
      "sslPort": 44393
    }
  }
}
Continue Reading

Fix for “Unable to bind to the underlying transport for [::]:<PortNumber>. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine.

I have been developing on Visual studio and IISExpress for sometime when I started getting the following error:
Unable to bind to the underlying transport for [::]:50160. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine.

Deleting the .vs folder in the application or the C:\Users\<UserName>\Documents\IISExpress\config folder, restarting the IISExpress or machine,  did not help nor did adding the “::”  value to the registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\ListenOnlyList
image

What finally worked for me when I ran the following command, I see that the ports from 49697 to 50503 were reserved by Docker.  So I changed the application port to 50504 and the application was able to run correctly on IISExpress.

netsh interface ipv4 show excludedportrange protocol=tcp

image

Continue Reading

System.BadImageFormatException: Index not found. (Exception from HRESULT: 0x80131124)

If you get a

An unhandled exception has occurred while executing the request. 
System.BadImageFormatException: Index not found. (Exception from HRESULT: 0x80131124)

error when publishing your website through Visual Studio, a couple of things to check are:

  • When publishing the application to Azure make sure that the “Remove Additional Files at destination” option is checked.

    image
  • Made sure that all the projects(only one) were being build as “Any CPU” in both “debug” and “release” configuration.
    image
Continue Reading