dapr/dapr · error

error parsing dapr-http-port flag: %w

Error message

error parsing dapr-http-port flag: %w

What it means

strconv.Atoi failed on the --dapr-http-port flag value during runtime config init (pkg/runtime/config.go:412). The sidecar HTTP API port must be a base-10 integer; anything else (empty string, float, unit suffix, letters) aborts startup.

Source

Thrown at pkg/runtime/config.go:412

		workflowEventSink:          c.WorkflowEventSink,
	}

	if len(intc.standalone.ResourcesPath) == 0 && c.ComponentsPath != "" {
		intc.standalone.ResourcesPath = []string{c.ComponentsPath}
	}

	if intc.mode == modes.StandaloneMode {
		err := validation.ValidateSelfHostedAppID(intc.id)
		if err != nil {
			return nil, err
		}
	}

	var err error

	intc.httpPort, err = strconv.Atoi(c.DaprHTTPPort)
	if err != nil {
		return nil, fmt.Errorf("error parsing dapr-http-port flag: %w", err)
	}

	intc.apiGRPCPort, err = strconv.Atoi(c.DaprAPIGRPCPort)
	if err != nil {
		return nil, fmt.Errorf("error parsing dapr-grpc-port flag: %w", err)
	}

	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 {

View on GitHub (pinned to 74ad417027)

Solutions

  1. Pass a plain integer for --dapr-http-port (default 3500)
  2. If the value comes from an env var, verify it is set and numeric before launching (echo "$DAPR_HTTP_PORT")
  3. Inspect the rendered command line in the crash log and remove stray characters/units

Example fix

# before
DAPR_HTTP_PORT=${HTTP_PORT} ./daprd --dapr-http-port "${HTTP_PORT} "  # unset -> empty

# after
DAPR_HTTP_PORT=${HTTP_PORT:-3500} ./daprd --dapr-http-port "${DAPR_HTTP_PORT:-3500}"
Defensive patterns

Strategy: validation

Validate before calling

func validatePortFlags(c runtime.Config) error {
	for name, v := range map[string]string{
		"dapr-http-port": c.DaprHTTPPort,
		"dapr-grpc-port": c.DaprAPIGRPCPort,
		"profile-port":  c.ProfilePort,
	} {
		if _, err := strconv.Atoi(v); err != nil {
			return fmt.Errorf("flag %s=%q is not an integer", name, v)
		}
	}
	return nil
}

Type guard

func isIntPort(s string) bool {
	n, err := strconv.Atoi(strings.TrimSpace(s))
	return err == nil && n >= 0 && n <= 65535
}

Prevention

When it happens

Trigger: Passing --dapr-http-port with a non-integer such as "", "3500.0", "3500/tcp", or "http" — often caused by an unset env var interpolated into a launcher script.

Common situations: dapr run / daprd launched from CI or docker where the port comes from an environment variable that is unset (renders empty); typos in flags; templates appending units.

Related errors


AI-assisted analysis of dapr/dapr@74ad417027 (2026-08-16). Data as JSON: /api/errors/6ec14855abfd839b. Report an issue: GitHub.