Search code examples
azure-service-fabricservice-fabric-stateless

Azure Service Fabric - Failed to bind to address address already in use


I get the following error when running a basic Stateless Service (out of the box template with WeatherForecastController) on a local (again fresh and out of the box) azure fabric cluster. The same error shows for 4 of the 5 nodes (only Node4 does not have the error) despite the app only running on node 2.

Unhealthy event: SourceId='System.RA', Property='ReplicaOpenStatus', HealthState='Warning', ConsiderWarningAsError=false. Replica had multiple failures during open on _Node_1. API call: IStatelessServiceInstance.Open(); Error = System.IO.IOException (-2146232800) Failed to bind to address http://[::]:8390: address already in use.

I have tried changing the ipaddress in the ServiceManifest.xml but just get the same error again.

What on earth is going on?


Solution

  • Your local dev cluster runs on one machine, the first service replica claims the port. If the others cannot share the port, so they fail to start.

    To solve this, either:

    • Run one service instance/replica on your local dev cluster (use the Local.1Node.xml publish profile)
    • Run multiple services, but use dynamic ports (omit the Port in the endpoint spec of the service manifest)
    • Use a platform that supports port sharing, like http.sys

    More info here.