dapr/dapr · error
failed to get free port for internal grpc server: %w
Error message
failed to get free port for internal grpc server: %w
What it means
ports.GetStablePort failed while allocating the internal gRPC port (pkg/runtime/config.go:437). When --dapr-internal-grpc-port is unset or "0", Dapr derives a deterministic port in the 47300-49347 range from the app ID so restarts reuse it; this error means that derivation/acquisition failed. The wrapped error carries the exact cause.
Source
Thrown at pkg/runtime/config.go:437
intc.profilePort, err = strconv.Atoi(c.ProfilePort)
if err != nil {
return nil, fmt.Errorf("error parsing profile-port flag: %w", err)
}
if c.DaprInternalGRPCPort != "" && c.DaprInternalGRPCPort != "0" {
intc.internalGRPCPort, err = strconv.Atoi(c.DaprInternalGRPCPort)
if err != nil {
return nil, fmt.Errorf("error parsing dapr-internal-grpc-port: %w", err)
}
} else {
// Get a "stable random" port in the range 47300-49,347 if it can be
// acquired using a deterministic algorithm that returns the same value if
// the same app is restarted
// Otherwise, the port will be random.
intc.internalGRPCPort, err = ports.GetStablePort(47300, intc.id)
if err != nil {
return nil, fmt.Errorf("failed to get free port for internal grpc server: %w", err)
}
}
if c.DaprPublicPort != "" {
var port int
port, err = strconv.Atoi(c.DaprPublicPort)
if err != nil {
return nil, fmt.Errorf("error parsing dapr-public-port: %w", err)
}
intc.publicPort = &port
}
if c.ApplicationPort != "" {
intc.appConnectionConfig.Port, err = strconv.Atoi(c.ApplicationPort)
if err != nil {
return nil, fmt.Errorf("error parsing app-port: %w", err)View on GitHub (pinned to 74ad417027)
Solutions
- Set --dapr-internal-grpc-port explicitly to a known-free port (e.g. 50002) to bypass stable-port derivation entirely
- Inspect the wrapped error to see the exact failure inside GetStablePort
- Verify the app ID (--app-id / id field) is a non-empty sane value
Example fix
# before daprd --app-id myapp # relies on GetStablePort, fails # after daprd --app-id myapp --dapr-internal-grpc-port 50002
Defensive patterns
Strategy: fallback
Prevention
- Pin --dapr-internal-grpc-port to a known-free port in orchestration instead of relying on stable-port derivation
- Keep --app-id non-empty and stable so deterministic port derivation has sane input
- Treat any GetStablePort failure as actionable: read the wrapped error before retrying
When it happens
Trigger: Calling daprd without --dapr-internal-grpc-port where GetStablePort(47300, appID) errors — e.g. an appID that the deterministic algorithm rejects, or an environment failure inside the port helper.
Common situations: Sidecars launched with unusual/empty app IDs in custom hosts; embedders constructing runtime configs programmatically without a valid id; rare platform errors surfaced by the helper.
Related errors
- error parsing dapr-http-port flag: %w
- error parsing dapr-grpc-port flag: %w
- error parsing profile-port flag: %w
- error parsing dapr-internal-grpc-port: %w
- error parsing dapr-public-port: %w
AI-assisted analysis of dapr/dapr@74ad417027 (2026-08-16).
Data as JSON: /api/errors/d3e7a522076351df.
Report an issue: GitHub.